aboutsummaryrefslogtreecommitdiff
path: root/internal/testgit/repo_run.go
diff options
context:
space:
mode:
Diffstat (limited to 'internal/testgit/repo_run.go')
-rw-r--r--internal/testgit/repo_run.go7
1 files changed, 7 insertions, 0 deletions
diff --git a/internal/testgit/repo_run.go b/internal/testgit/repo_run.go
index 8022835e..162a0d72 100644
--- a/internal/testgit/repo_run.go
+++ b/internal/testgit/repo_run.go
@@ -11,12 +11,14 @@ import (
func (testRepo *TestRepo) Run(tb testing.TB, args ...string) string {
tb.Helper()
out := testRepo.runBytes(tb, nil, testRepo.dir, args...)
+
return strings.TrimSpace(string(out))
}
// RunBytes executes git and returns raw output bytes.
func (testRepo *TestRepo) RunBytes(tb testing.TB, args ...string) []byte {
tb.Helper()
+
return testRepo.runBytes(tb, nil, testRepo.dir, args...)
}
@@ -24,12 +26,14 @@ func (testRepo *TestRepo) RunBytes(tb testing.TB, args ...string) []byte {
func (testRepo *TestRepo) RunInput(tb testing.TB, stdin []byte, args ...string) string {
tb.Helper()
out := testRepo.runBytes(tb, stdin, testRepo.dir, args...)
+
return strings.TrimSpace(string(out))
}
// RunInputBytes executes git with stdin and returns raw output bytes.
func (testRepo *TestRepo) RunInputBytes(tb testing.TB, stdin []byte, args ...string) []byte {
tb.Helper()
+
return testRepo.runBytes(tb, stdin, testRepo.dir, args...)
}
@@ -38,13 +42,16 @@ func (testRepo *TestRepo) runBytes(tb testing.TB, stdin []byte, dir string, args
//nolint:noctx
cmd := exec.Command("git", args...) //#nosec G204
cmd.Dir = dir
+
cmd.Env = testRepo.env
if stdin != nil {
cmd.Stdin = bytes.NewReader(stdin)
}
+
out, err := cmd.CombinedOutput()
if err != nil {
tb.Fatalf("git %v failed: %v\n%s", args, err, out)
}
+
return out
}