Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitaly.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPatrick Steinhardt <psteinhardt@gitlab.com>2021-05-20 13:34:35 +0300
committerPatrick Steinhardt <psteinhardt@gitlab.com>2021-05-20 19:05:17 +0300
commit0ee0fc45f6feebae2983cec02494273d91ca485c (patch)
tree2e7d25bc425ba85bd8d8b9791a938ff0cb72b4f0
parent5f67906e75f9504c7d0d2f1327b5faa92808759d (diff)
testhelper: Fix tests when running in an interactive rebase
With the same reasoning as for the parent commit, unset Git-specific environment variables in our testhelper.
-rw-r--r--internal/testhelper/configure.go20
1 files changed, 20 insertions, 0 deletions
diff --git a/internal/testhelper/configure.go b/internal/testhelper/configure.go
index 7b011a76c..01a6a0851 100644
--- a/internal/testhelper/configure.go
+++ b/internal/testhelper/configure.go
@@ -55,6 +55,26 @@ func Configure() func() {
// ConfigureGit configures git for test purpose
func ConfigureGit() error {
+ // We cannot use gittest here given that we ain't got no config yet. We thus need to
+ // manually resolve the git executable, which is either stored in below envvar if
+ // executed via our Makefile, or else just git as resolved via PATH.
+ gitPath := "git"
+ if path, ok := os.LookupEnv("GITALY_TESTING_GIT_BINARY"); ok {
+ gitPath = path
+ }
+
+ // Unset environment variables which have an effect on Git itself.
+ cmd := exec.Command(gitPath, "rev-parse", "--local-env-vars")
+ envvars, err := cmd.CombinedOutput()
+ if err != nil {
+ return fmt.Errorf("error computing local envvars: %w", err)
+ }
+ for _, envvar := range strings.Split(string(envvars), "\n") {
+ if err := os.Unsetenv(envvar); err != nil {
+ return fmt.Errorf("error unsetting envvar: %w", err)
+ }
+ }
+
_, currentFile, _, ok := runtime.Caller(0)
if !ok {
return fmt.Errorf("could not get caller info")