AuthenticatedCommand is a wrapper around Command that included configuration to use gh as the credential helper for git.
(ctx context.Context, credentialPattern CredentialPattern, args ...string)
| 140 | // AuthenticatedCommand is a wrapper around Command that included configuration to use gh |
| 141 | // as the credential helper for git. |
| 142 | func (c *Client) AuthenticatedCommand(ctx context.Context, credentialPattern CredentialPattern, args ...string) (*Command, error) { |
| 143 | if c.GhPath == "" { |
| 144 | // Assumes that gh is in PATH. |
| 145 | c.GhPath = "gh" |
| 146 | } |
| 147 | credHelper := fmt.Sprintf("!%q auth git-credential", c.GhPath) |
| 148 | |
| 149 | var preArgs []string |
| 150 | if credentialPattern == disallowedCredentialPattern { |
| 151 | return nil, fmt.Errorf("empty credential pattern is not allowed unless provided explicitly") |
| 152 | } else if credentialPattern == AllMatchingCredentialsPattern { |
| 153 | preArgs = []string{"-c", "credential.helper="} |
| 154 | preArgs = append(preArgs, "-c", fmt.Sprintf("credential.helper=%s", credHelper)) |
| 155 | } else { |
| 156 | preArgs = []string{"-c", fmt.Sprintf("credential.%s.helper=", credentialPattern.pattern)} |
| 157 | preArgs = append(preArgs, "-c", fmt.Sprintf("credential.%s.helper=%s", credentialPattern.pattern, credHelper)) |
| 158 | } |
| 159 | |
| 160 | args = append(preArgs, args...) |
| 161 | return c.Command(ctx, args...) |
| 162 | } |
| 163 | |
| 164 | func (c *Client) Remotes(ctx context.Context) (RemoteSet, error) { |
| 165 | remoteArgs := []string{"remote", "-v"} |