From 2885c5b4d27d913c04fa680d46ce5d9febe5643d Mon Sep 17 00:00:00 2001 From: Runxi Yu Date: Sun, 7 Jun 2026 08:29:52 +0000 Subject: internal/testgit: CommitTree should accept identities --- internal/testgit/command.go | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'internal/testgit/command.go') diff --git a/internal/testgit/command.go b/internal/testgit/command.go index a7d8651a..dc960877 100644 --- a/internal/testgit/command.go +++ b/internal/testgit/command.go @@ -3,6 +3,8 @@ package testgit import ( "io" "os/exec" + "slices" + "strings" "testing" ) @@ -34,3 +36,17 @@ func (repo *Repo) Run( return cmd.Output() //nolint:wrapcheck } + +func setEnv(env []string, key string, value string) []string { + prefix := key + "=" + i := slices.IndexFunc(env, func(entry string) bool { + return strings.HasPrefix(entry, prefix) + }) + if i >= 0 { + env[i] = prefix + value + + return env + } + + return append(env, prefix+value) +} -- cgit v1.3.1-10-gc9f91