MCPcopy Create free account
hub / github.com/github/gh-aw / getCurrentUser

Function getCurrentUser

pkg/cli/project_command.go:212–226  ·  view source on GitHub ↗

getCurrentUser gets the current authenticated user's login

(ctx context.Context)

Source from the content-addressed store, hash-verified

210
211// getCurrentUser gets the current authenticated user's login
212func getCurrentUser(ctx context.Context) (string, error) {
213 projectLog.Print("Getting current user")
214
215 output, err := workflow.RunGH("Fetching user info...", "api", "user", "--jq", ".login")
216 if err != nil {
217 return "", fmt.Errorf("failed to get current user: %w", err)
218 }
219
220 login := strings.TrimSpace(string(output))
221 if login == "" {
222 return "", errors.New("failed to get current user login")
223 }
224
225 return login, nil
226}
227
228// validateOwner validates that the owner exists
229func validateOwner(ctx context.Context, ownerType, owner string, verbose bool) error {

Callers 1

RunProjectNewFunction · 0.85

Calls 3

RunGHFunction · 0.92
PrintMethod · 0.80
ErrorfMethod · 0.45

Tested by

no test coverage detected