gitOutput runs a read-only git command and returns trimmed stdout.
(args ...string)
| 8 | |
| 9 | // gitOutput runs a read-only git command and returns trimmed stdout. |
| 10 | func gitOutput(args ...string) (string, error) { |
| 11 | cmd := exec.Command("git", args...) |
| 12 | out, err := cmd.Output() |
| 13 | if err != nil { |
| 14 | var exitErr *exec.ExitError |
| 15 | if errors.As(err, &exitErr) { |
| 16 | return "", exitErr |
| 17 | } |
| 18 | return "", err |
| 19 | } |
| 20 | return strings.TrimSpace(string(out)), nil |
| 21 | } |
| 22 | |
| 23 | // gitRun runs a git command with stdout/stderr connected to the |
| 24 | // terminal. |
no test coverage detected