aboutsummaryrefslogtreecommitdiff
path: root/internal/testgit/command.go
diff options
context:
space:
mode:
Diffstat (limited to 'internal/testgit/command.go')
-rw-r--r--internal/testgit/command.go16
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)
+}