aboutsummaryrefslogtreecommitdiff
path: root/internal/testgit/commit.go
diff options
context:
space:
mode:
authorGravatar Runxi Yu2026-06-07 08:57:29 +0000
committerGravatar Runxi Yu2026-06-07 08:57:29 +0000
commitf0b42f343247aea940e5b465ca2221a731f617f5 (patch)
tree2a592767d0bf96b784cb0b957cfa1ecd63980fa5 /internal/testgit/commit.go
parentobject/commit: noinlineerr (diff)
signatureNo signature
internal/testgit: Fix lints too
Diffstat (limited to 'internal/testgit/commit.go')
-rw-r--r--internal/testgit/commit.go9
1 files changed, 8 insertions, 1 deletions
diff --git a/internal/testgit/commit.go b/internal/testgit/commit.go
index b33b8904..a608d2fa 100644
--- a/internal/testgit/commit.go
+++ b/internal/testgit/commit.go
@@ -34,7 +34,9 @@ func (repo *Repo) CommitTree(
) (id.ObjectID, error) {
tb.Helper()
- args := []string{"commit-tree"}
+ args := make([]string, 0, 1+2*len(parents)+4)
+ args = append(args, "commit-tree")
+
for _, parent := range parents {
args = append(args, "-p", parent.String())
}
@@ -45,18 +47,23 @@ func (repo *Repo) CommitTree(
if opts.Author.Name != "" {
cmd.Env = setEnv(cmd.Env, "GIT_AUTHOR_NAME", opts.Author.Name)
}
+
if opts.Author.Email != "" {
cmd.Env = setEnv(cmd.Env, "GIT_AUTHOR_EMAIL", opts.Author.Email)
}
+
if opts.AuthorDate != "" {
cmd.Env = setEnv(cmd.Env, "GIT_AUTHOR_DATE", opts.AuthorDate)
}
+
if opts.Committer.Name != "" {
cmd.Env = setEnv(cmd.Env, "GIT_COMMITTER_NAME", opts.Committer.Name)
}
+
if opts.Committer.Email != "" {
cmd.Env = setEnv(cmd.Env, "GIT_COMMITTER_EMAIL", opts.Committer.Email)
}
+
if opts.CommitterDate != "" {
cmd.Env = setEnv(cmd.Env, "GIT_COMMITTER_DATE", opts.CommitterDate)
}