runGitSplit runs git with stdout and stderr kept apart, for the callers that quote the failure back to the user. runGit's combined output cannot be quoted safely. Git writes the diff to stdout and its diagnosis to stderr, so a command killed mid-write leaves a tail made entirely of diff content — r
(ctx context.Context, args ...string)
| 669 | // included: a killed process reports the signal rather than the reason, and |
| 670 | // the reason is what the caller needs. |
| 671 | func (p *Provider) runGitSplit(ctx context.Context, args ...string) (string, string, error) { |
| 672 | if p.runner != nil { |
| 673 | stdout, stderr, err := p.runner.RunSplit(ctx, p.repoDir, args...) |
| 674 | if ctx.Err() != nil && err != nil { |
| 675 | return "", "", ctx.Err() |
| 676 | } |
| 677 | return stdout, stderr, err |
| 678 | } |
| 679 | |
| 680 | cmd := exec.CommandContext(ctx, "git", args...) |
| 681 | cmd.Dir = p.repoDir |
| 682 | |
| 683 | var stdout, stderr bytes.Buffer |
| 684 | cmd.Stdout = &stdout |
| 685 | cmd.Stderr = &stderr |
| 686 | |
| 687 | err := cmd.Run() |
| 688 | if ctx.Err() != nil && err != nil && cmd.ProcessState != nil && cmd.ProcessState.ExitCode() == -1 { |
| 689 | return "", "", ctx.Err() |
| 690 | } |
| 691 | return stdout.String(), stderr.String(), err |
| 692 | } |
| 693 | |
| 694 | // gitDiagLimit bounds how much of git's stderr is quoted back in an error. |
| 695 | // Git's own diagnosis is a line or two, so the ceiling is a backstop for the |
no test coverage detected