getCurrentGitHubUsername gets the current GitHub username from gh CLI
(ctx context.Context)
| 259 | |
| 260 | // getCurrentGitHubUsername gets the current GitHub username from gh CLI |
| 261 | func 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 | } |
no test coverage detected