aboutsummaryrefslogtreecommitdiff
path: root/internal/testgit/command.go
diff options
context:
space:
mode:
authorGravatar Runxi Yu2026-06-06 16:31:02 +0000
committerGravatar Runxi Yu2026-06-06 16:31:02 +0000
commite083d4dc1f455bd57b2f9d473fb44f5ee5ccbbe3 (patch)
tree65227398b7db087a7aff211daa4000715bda399c /internal/testgit/command.go
parenttestgit sucks (diff)
signatureNo signature
internal/testgit: hash-object and command
Diffstat (limited to 'internal/testgit/command.go')
-rw-r--r--internal/testgit/command.go36
1 files changed, 36 insertions, 0 deletions
diff --git a/internal/testgit/command.go b/internal/testgit/command.go
new file mode 100644
index 00000000..cdb87a49
--- /dev/null
+++ b/internal/testgit/command.go
@@ -0,0 +1,36 @@
+package testgit
+
+import (
+ "io"
+ "os/exec"
+ "testing"
+)
+
+func (repo *Repo) Command(
+ tb testing.TB,
+ command string,
+ args ...string,
+) *exec.Cmd {
+ tb.Helper()
+
+ cmd := exec.CommandContext(tb.Context(), command, args...)
+ cmd.Dir = repo.path
+ cmd.Env = repo.env
+
+ return cmd
+}
+
+func (repo *Repo) Run(
+ tb testing.TB,
+ stdin io.Reader,
+ command string,
+ args ...string,
+) (stdout []byte, err error) {
+ tb.Helper()
+
+ cmd := repo.Command(tb, command, args...)
+
+ cmd.Stdin = stdin
+
+ return cmd.Output()
+}