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)
| 485 | // credential-helper flags before all args, so a -C prefix would be displaced; |
| 486 | // instead we strip it and apply it as cmd.Dir. |
| 487 | func authenticatedCommand(client *git.Client, credentialPattern git.CredentialPattern, args []string) (*git.Command, error) { |
| 488 | if args[0] == "-C" { |
| 489 | cmd, err := client.AuthenticatedCommand(context.Background(), credentialPattern, args[2:]...) |
| 490 | if err != nil { |
| 491 | return nil, err |
| 492 | } |
| 493 | cmd.Dir = args[1] |
| 494 | return cmd, nil |
| 495 | } |
| 496 | return client.AuthenticatedCommand(context.Background(), credentialPattern, args...) |
| 497 | } |
| 498 | |
| 499 | type PRResolver interface { |
| 500 | Resolve() (*api.PullRequest, ghrepo.Interface, error) |