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

Method RunSplit

internal/gitcmd/runner.go:72–87  ·  view source on GitHub ↗

RunSplit executes a git command and returns stdout and stderr separately.

(ctx context.Context, repoDir string, args ...string)

Source from the content-addressed store, hash-verified

70
71// RunSplit executes a git command and returns stdout and stderr separately.
72func (r *Runner) RunSplit(ctx context.Context, repoDir string, args ...string) (string, string, error) {
73 if err := r.acquire(ctx); err != nil {
74 return "", "", err
75 }
76 defer r.release()
77
78 cmd := exec.CommandContext(ctx, "git", args...)
79 cmd.Dir = repoDir
80
81 var stdout, stderr bytes.Buffer
82 cmd.Stdout = &stdout
83 cmd.Stderr = &stderr
84
85 err := cmd.Run()
86 return stdout.String(), stderr.String(), err
87}
88
89// Stream acquires the semaphore, starts a git command, and passes its stdout
90// as an io.Reader to consume. The semaphore is held for the full duration.

Callers 2

TestRunner_RunSplitFunction · 0.80
runGitGrepMethod · 0.80

Calls 4

acquireMethod · 0.95
releaseMethod · 0.95
RunMethod · 0.45
StringMethod · 0.45

Tested by 1

TestRunner_RunSplitFunction · 0.64