MCPcopy Create free account
hub / github.com/alibaba/open-code-review / command

Method command

internal/gitcmd/runner.go:121–142  ·  view source on GitHub ↗
(ctx context.Context, repoDir string, args ...string)

Source from the content-addressed store, hash-verified

119}
120
121func (r *Runner) command(ctx context.Context, repoDir string, args ...string) *exec.Cmd {
122 if len(r.configArgs) > 0 {
123 args = append(append([]string{}, r.configArgs...), args...)
124 }
125 cmd := exec.CommandContext(ctx, "git", args...)
126 cmd.Dir = repoDir
127 if r.localOnly {
128 for _, entry := range cmd.Environ() {
129 key, _, _ := strings.Cut(entry, "=")
130 switch strings.ToUpper(key) {
131 case "GIT_CEILING_DIRECTORIES", "GIT_CONFIG_GLOBAL", "GIT_CONFIG_SYSTEM", "GIT_CONFIG_NOSYSTEM":
132 default:
133 if strings.HasPrefix(strings.ToUpper(key), "GIT_") {
134 continue
135 }
136 }
137 cmd.Env = append(cmd.Env, entry)
138 }
139 cmd.Env = append(cmd.Env, "GIT_NO_LAZY_FETCH=1", "GIT_ALLOW_PROTOCOL=", "GIT_OPTIONAL_LOCKS=0")
140 }
141 return cmd
142}
143
144// New creates a Runner that allows at most maxConcurrent simultaneous git
145// subprocesses. If maxConcurrent <= 0 the default (16) is used.

Callers 3

captureMethod · 0.95
StreamMethod · 0.95

Calls

no outgoing calls