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>2022-05-19 13:33:12 +0300
committerPatrick Steinhardt <psteinhardt@gitlab.com>2022-05-24 10:08:23 +0300
commit4ed64a6b4b5ae67e3dbb99291f020e0c37d6a43f (patch)
tree2b296a0f8518bd9c9ce8691778c48bd6fc234c3b
parent71bd8570f254b69a9fb3ade374e255656f4ba54b (diff)
git: Extend gitconfig workaround to cover XDG-config
Our command factory is injecting a set of environment variables that override the location of Git's configuration files when running tests so that we are running in a well-defined environment that doesn't depend on what the user has configured. This workaround doesn't cover the XDG config though, which is located in `$XDG_CONFIG_HOME/git/config`, where `$XDG_CONFIG_HOME` is typically `$HOME/.config`. Fix this oversight by also overriding `XDG_CONFIG_HOME`, as documented in git(1). Unfortunately, there isn't a more direct way to override this. On the other hand it doesn't matter much: previously, we always filtered out this environment variable in case it was set, so there cannot be any users that depend on it being set.
-rw-r--r--internal/git/command_factory.go1
-rw-r--r--internal/git/command_factory_test.go3
2 files changed, 4 insertions, 0 deletions
diff --git a/internal/git/command_factory.go b/internal/git/command_factory.go
index 83e9a1060..17b2a85de 100644
--- a/internal/git/command_factory.go
+++ b/internal/git/command_factory.go
@@ -168,6 +168,7 @@ func setupGitExecutionEnvironments(cfg config.Cfg, factoryCfg execCommandFactory
sharedEnvironment = append(sharedEnvironment,
"GIT_CONFIG_GLOBAL=/dev/null",
"GIT_CONFIG_SYSTEM=/dev/null",
+ "XDG_CONFIG_HOME=/dev/null",
)
}
diff --git a/internal/git/command_factory_test.go b/internal/git/command_factory_test.go
index 45ff1c9ce..3c3aec4fb 100644
--- a/internal/git/command_factory_test.go
+++ b/internal/git/command_factory_test.go
@@ -175,6 +175,7 @@ func TestCommandFactory_ExecutionEnvironment(t *testing.T) {
"GIT_TERMINAL_PROMPT=0",
"GIT_CONFIG_GLOBAL=/dev/null",
"GIT_CONFIG_SYSTEM=/dev/null",
+ "XDG_CONFIG_HOME=/dev/null",
},
})
})
@@ -189,6 +190,7 @@ func TestCommandFactory_ExecutionEnvironment(t *testing.T) {
"GIT_TERMINAL_PROMPT=0",
"GIT_CONFIG_GLOBAL=/dev/null",
"GIT_CONFIG_SYSTEM=/dev/null",
+ "XDG_CONFIG_HOME=/dev/null",
},
})
})
@@ -288,6 +290,7 @@ func TestCommandFactory_ExecutionEnvironment(t *testing.T) {
"GIT_TERMINAL_PROMPT=0",
"GIT_CONFIG_GLOBAL=/dev/null",
"GIT_CONFIG_SYSTEM=/dev/null",
+ "XDG_CONFIG_HOME=/dev/null",
},
})
})