From 94482cb2c97aa215f83940643c5d4c0933727dcb Mon Sep 17 00:00:00 2001 From: Runxi Yu Date: Sat, 21 Feb 2026 13:38:02 +0800 Subject: *: Modernize and lint; add CI --- internal/testgit/repo_commit_tree.go | 3 ++- internal/testgit/repo_new.go | 6 +----- internal/testgit/repo_run.go | 3 ++- 3 files changed, 5 insertions(+), 7 deletions(-) (limited to 'internal/testgit') diff --git a/internal/testgit/repo_commit_tree.go b/internal/testgit/repo_commit_tree.go index f8d78421..763474c2 100644 --- a/internal/testgit/repo_commit_tree.go +++ b/internal/testgit/repo_commit_tree.go @@ -9,7 +9,8 @@ import ( // CommitTree creates a commit from a tree and message, optionally with parents. func (testRepo *TestRepo) CommitTree(tb testing.TB, tree objectid.ObjectID, message string, parents ...objectid.ObjectID) objectid.ObjectID { tb.Helper() - args := []string{"commit-tree", tree.String()} + args := make([]string, 0, 2+2*len(parents)+2) + args = append(args, "commit-tree", tree.String()) for _, p := range parents { args = append(args, "-p", p.String()) } diff --git a/internal/testgit/repo_new.go b/internal/testgit/repo_new.go index 605eedd2..8120a9a2 100644 --- a/internal/testgit/repo_new.go +++ b/internal/testgit/repo_new.go @@ -26,11 +26,7 @@ func NewRepo(tb testing.TB, opts RepoOptions) *TestRepo { tb.Fatalf("invalid algorithm: %v", algo) } - dir, err := os.MkdirTemp("", "furgit-testgit-*") - if err != nil { - tb.Fatalf("create temp dir: %v", err) - } - tb.Cleanup(func() { _ = os.RemoveAll(dir) }) + dir := tb.TempDir() testRepo := &TestRepo{ dir: dir, diff --git a/internal/testgit/repo_run.go b/internal/testgit/repo_run.go index aafcc923..8022835e 100644 --- a/internal/testgit/repo_run.go +++ b/internal/testgit/repo_run.go @@ -35,7 +35,8 @@ func (testRepo *TestRepo) RunInputBytes(tb testing.TB, stdin []byte, args ...str func (testRepo *TestRepo) runBytes(tb testing.TB, stdin []byte, dir string, args ...string) []byte { tb.Helper() - cmd := exec.Command("git", args...) + //nolint:noctx + cmd := exec.Command("git", args...) //#nosec G204 cmd.Dir = dir cmd.Env = testRepo.env if stdin != nil { -- cgit v1.3.1-10-gc9f91