authenticatedCommand builds an authenticated git command, transparently handling a leading -C prefix. AuthenticatedCommand prepends credential-helper flags before all args, so a -C prefix would be displaced; instead we strip it and apply it as cmd.Dir.
(client *git.Client, credentialPattern git.CredentialPattern, args []string)
| 386 | // credential-helper flags before all args, so a -C prefix would be displaced; |
| 387 | // instead we strip it and apply it as cmd.Dir. |
| 388 | func authenticatedCommand(client *git.Client, credentialPattern git.CredentialPattern, args []string) (*git.Command, error) { |
| 389 | if args[0] == "-C" { |
| 390 | cmd, err := client.AuthenticatedCommand(context.Background(), credentialPattern, args[2:]...) |
| 391 | if err != nil { |
| 392 | return nil, err |
| 393 | } |
| 394 | cmd.Dir = args[1] |
| 395 | return cmd, nil |
| 396 | } |
| 397 | return client.AuthenticatedCommand(context.Background(), credentialPattern, args...) |
| 398 | } |
| 399 | |
| 400 | type PRResolver interface { |
| 401 | Resolve() (*api.PullRequest, ghrepo.Interface, error) |