From e083d4dc1f455bd57b2f9d473fb44f5ee5ccbbe3 Mon Sep 17 00:00:00 2001 From: Runxi Yu Date: Sat, 6 Jun 2026 16:31:02 +0000 Subject: internal/testgit: hash-object and command --- internal/testgit/command.go | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 internal/testgit/command.go (limited to 'internal/testgit/command.go') 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() +} -- cgit v1.3.1-10-gc9f91