diff options
| author | 2026-06-07 08:29:52 +0000 | |
|---|---|---|
| committer | 2026-06-07 08:31:39 +0000 | |
| commit | 2885c5b4d27d913c04fa680d46ce5d9febe5643d (patch) | |
| tree | dd4fe91749e450bc46ed4ec23c727b6a0d4d91ba /internal/testgit/command.go | |
| parent | internal/testgit: I don't want exhaustruct:ignore here actually (diff) | |
| signature | No signature | |
internal/testgit: CommitTree should accept identities
Diffstat (limited to 'internal/testgit/command.go')
| -rw-r--r-- | internal/testgit/command.go | 16 |
1 files changed, 16 insertions, 0 deletions
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) +} |
