diff options
author | Pavlo Strokov <pstrokov@gitlab.com> | 2022-08-17 15:33:49 +0300 |
---|---|---|
committer | Pavlo Strokov <pstrokov@gitlab.com> | 2022-08-17 15:33:49 +0300 |
commit | a58eceae78be70404e9e48dcf8d402254923c096 (patch) | |
tree | 3ef4948179b2cfaeb77ceda34948f8509f5f70c6 /internal | |
parent | 4807366d4977d267f86df45fdb1214110c7f927c (diff) | |
parent | 17419f5f7aa0a38485b47eccc6319e4afe560200 (diff) |
Merge branch 'pks-makefile-refactor-git-target' into 'master'
Makefile: Refactor `make git` target
See merge request gitlab-org/gitaly!4804
Diffstat (limited to 'internal')
-rw-r--r-- | internal/git/command_factory_test.go | 1 | ||||
-rw-r--r-- | internal/git/execution_environment.go | 12 | ||||
-rw-r--r-- | internal/git/execution_environment_test.go | 4 |
3 files changed, 15 insertions, 2 deletions
diff --git a/internal/git/command_factory_test.go b/internal/git/command_factory_test.go index 7414f3bbf..d4847028a 100644 --- a/internal/git/command_factory_test.go +++ b/internal/git/command_factory_test.go @@ -210,6 +210,7 @@ func TestCommandFactory_ExecutionEnvironment(t *testing.T) { }, git.ExecutionEnvironment{ BinaryPath: "/path/to/env_git", EnvironmentVariables: []string{ + "NO_SET_GIT_TEMPLATE_DIR=YesPlease", "LANG=en_US.UTF-8", "GIT_TERMINAL_PROMPT=0", "GIT_CONFIG_GLOBAL=/dev/null", diff --git a/internal/git/execution_environment.go b/internal/git/execution_environment.go index 99aa795c3..9de1a0b94 100644 --- a/internal/git/execution_environment.go +++ b/internal/git/execution_environment.go @@ -87,8 +87,17 @@ type DistributedGitEnvironmentConstructor struct{} // `GITALY_TESTING_GIT_BINARY` environment variable is set. func (c DistributedGitEnvironmentConstructor) Construct(cfg config.Cfg) (ExecutionEnvironment, error) { binaryPath := cfg.Git.BinPath + var environmentVariables []string if override := os.Getenv("GITALY_TESTING_GIT_BINARY"); binaryPath == "" && override != "" { binaryPath = override + environmentVariables = []string{ + // When using Git's bin-wrappers as testing binary then the wrapper will + // automatically set up the location of the Git templates and export the + // environment variable. This would override our own defaults though and + // thus leads to diverging behaviour. To fix this we simply ask the bin + // wrappers not to do this. + "NO_SET_GIT_TEMPLATE_DIR=YesPlease", + } } if binaryPath == "" { @@ -96,7 +105,8 @@ func (c DistributedGitEnvironmentConstructor) Construct(cfg config.Cfg) (Executi } return ExecutionEnvironment{ - BinaryPath: binaryPath, + BinaryPath: binaryPath, + EnvironmentVariables: environmentVariables, }, nil } diff --git a/internal/git/execution_environment_test.go b/internal/git/execution_environment_test.go index 8432b8724..5340110a5 100644 --- a/internal/git/execution_environment_test.go +++ b/internal/git/execution_environment_test.go @@ -46,7 +46,9 @@ func TestDistributedGitEnvironmentConstructor(t *testing.T) { defer execEnv.Cleanup() require.Equal(t, "/foo/bar", execEnv.BinaryPath) - require.Equal(t, []string(nil), execEnv.EnvironmentVariables) + require.Equal(t, []string{ + "NO_SET_GIT_TEMPLATE_DIR=YesPlease", + }, execEnv.EnvironmentVariables) }) t.Run("configuration overrides environment variable", func(t *testing.T) { |