MCPcopy
hub / github.com/cli/cli / Command

Method Command

git/client.go:77–99  ·  view source on GitHub ↗
(ctx context.Context, args ...string)

Source from the content-addressed store, hash-verified

75}
76
77func (c *Client) Command(ctx context.Context, args ...string) (*Command, error) {
78 if c.RepoDir != "" {
79 args = append([]string{"-C", c.RepoDir}, args...)
80 }
81 commandContext := exec.CommandContext
82 if c.commandContext != nil {
83 commandContext = c.commandContext
84 }
85 var err error
86 c.mu.Lock()
87 if c.GitPath == "" {
88 c.GitPath, err = resolveGitPath()
89 }
90 c.mu.Unlock()
91 if err != nil {
92 return nil, err
93 }
94 cmd := commandContext(ctx, c.GitPath, args...)
95 cmd.Stderr = c.Stderr
96 cmd.Stdin = c.Stdin
97 cmd.Stdout = c.Stdout
98 return &Command{cmd}, nil
99}
100
101// CredentialPattern is used to inform AuthenticatedCommand which patterns Git should match
102// against when trying to find credentials. It is a little over-engineered as a type because we

Callers 15

TestClientCommandFunction · 0.95
initRepoFunction · 0.95
AuthenticatedCommandMethod · 0.95
RemotesMethod · 0.95
UpdateRemoteURLMethod · 0.95
SetRemoteResolutionMethod · 0.95
CurrentBranchMethod · 0.95
ShowRefsMethod · 0.95
ConfigMethod · 0.95
CommitsMethod · 0.95
lookupCommitMethod · 0.95

Calls 1

resolveGitPathFunction · 0.85

Tested by 8

TestClientCommandFunction · 0.76
initRepoFunction · 0.76
fillCredentialsFunction · 0.76
createMockExecutableFunction · 0.64
newTestManagerFunction · 0.64