MCPcopy
hub / github.com/cli/cli / AuthenticatedCommand

Method AuthenticatedCommand

git/client.go:142–162  ·  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

140// AuthenticatedCommand is a wrapper around Command that included configuration to use gh
141// as the credential helper for git.
142func (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
164func (c *Client) Remotes(ctx context.Context) (RemoteSet, error) {
165 remoteArgs := []string{"remote", "-v"}

Callers 8

FetchMethod · 0.95
PullMethod · 0.95
PushMethod · 0.95
CloneMethod · 0.95
createFromLocalFunction · 0.80
FetchMethod · 0.80
executeCmdsFunction · 0.80

Calls 2

CommandMethod · 0.95
ErrorfMethod · 0.65

Tested by 1