RunSplit executes a git command and returns stdout and stderr separately.
(ctx context.Context, repoDir string, args ...string)
| 70 | |
| 71 | // RunSplit executes a git command and returns stdout and stderr separately. |
| 72 | func (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. |