diff options
| author | 2026-06-06 16:31:02 +0000 | |
|---|---|---|
| committer | 2026-06-06 16:31:02 +0000 | |
| commit | e083d4dc1f455bd57b2f9d473fb44f5ee5ccbbe3 (patch) | |
| tree | 65227398b7db087a7aff211daa4000715bda399c /internal/testgit/command.go | |
| parent | testgit sucks (diff) | |
| signature | No signature | |
internal/testgit: hash-object and command
Diffstat (limited to 'internal/testgit/command.go')
| -rw-r--r-- | internal/testgit/command.go | 36 |
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() +} |
