MCPcopy Create free account
hub / github.com/cli/cli / AuthenticatedCommand

Method AuthenticatedCommand

git/client.go:136–156  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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

Calls 2

CommandMethod · 0.95
ErrorfMethod · 0.65