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

Function getCurrentGitHubUsername

pkg/cli/trial_runner.go:261–273  ·  view source on GitHub ↗

getCurrentGitHubUsername gets the current GitHub username from gh CLI

(ctx context.Context)

Source from the content-addressed store, hash-verified

259
260// getCurrentGitHubUsername gets the current GitHub username from gh CLI
261func getCurrentGitHubUsername(ctx context.Context) (string, error) {
262 output, err := workflow.RunGHContext(ctx, "Fetching GitHub username...", "api", "user", "--jq", ".login")
263 if err != nil {
264 return "", fmt.Errorf("failed to get GitHub username: %w", err)
265 }
266
267 username := strings.TrimSpace(string(output))
268 if username == "" {
269 return "", errors.New("GitHub username is empty")
270 }
271
272 return username, nil
273}

Callers 1

RunWorkflowTrialsFunction · 0.85

Calls 2

RunGHContextFunction · 0.92
ErrorfMethod · 0.45

Tested by

no test coverage detected