getCurrentUser gets the current authenticated user's login
(ctx context.Context)
| 210 | |
| 211 | // getCurrentUser gets the current authenticated user's login |
| 212 | func 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 |
| 229 | func validateOwner(ctx context.Context, ownerType, owner string, verbose bool) error { |
no test coverage detected