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

Method Command

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

Source from the content-addressed store, hash-verified

76}
77
78func (c *Client) Command(ctx context.Context, args ...string) (*Command, error) {
79 if c.RepoDir != "" {
80 args = append([]string{"-C", c.RepoDir}, args...)
81 }
82 commandContext := exec.CommandContext
83 if c.commandContext != nil {
84 commandContext = c.commandContext
85 }
86 var err error
87 c.mu.Lock()
88 if c.GitPath == "" {
89 c.GitPath, err = resolveGitPath()
90 }
91 c.mu.Unlock()
92 if err != nil {
93 return nil, err
94 }
95 cmd := commandContext(ctx, c.GitPath, args...)
96 cmd.Stderr = c.Stderr
97 cmd.Stdin = c.Stdin
98 cmd.Stdout = c.Stdout
99 return &Command{cmd}, nil
100}
101
102// CredentialPattern is used to inform AuthenticatedCommand which patterns Git should match
103// 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
WorktreesMethod · 0.95
WorktreeRemoveMethod · 0.95
WorktreePruneMethod · 0.95
ConfigMethod · 0.95

Calls 1

resolveGitPathFunction · 0.85

Tested by 9

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