diff options
author | Patrick Steinhardt <psteinhardt@gitlab.com> | 2021-12-20 15:43:32 +0300 |
---|---|---|
committer | Patrick Steinhardt <psteinhardt@gitlab.com> | 2021-12-20 20:02:29 +0300 |
commit | ddfdf499b69b808fbbba486e3da83a1c73a0be76 (patch) | |
tree | 8ec46cea9fae9795bc912aba5011c354f839318c /internal/gitaly/hook/prereceive_test.go | |
parent | 359b13c634956f765dca9fbc7daf729f45a32f61 (diff) |
hook: Let custom hook scripts resolve Git via PATH
Custom hook scripts used in tests which use Git currently have the fully
qualified Git path injected into them such that we are sure that the
correct Git version is used. This was required until now given that we
didn't inject a PATH environment variable which had the correct Git
version prepended to it. As a result, we'd have executed the wrong Git
executables in these scripts, which would typically be our intercepting
Git wrappers in `internal/testhelper/testdata/home/bin`.
Now that we do properly set up PATH, this workaround isn't needed
anymore. Quite the reverse: the fact that we injected the full Git path
into these scripts only obscured the fact that we didn't set up the
environment as expected.
Adapt tests to always resolve Git via PATH to assert that we pick up the
correct executables.
Diffstat (limited to 'internal/gitaly/hook/prereceive_test.go')
-rw-r--r-- | internal/gitaly/hook/prereceive_test.go | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/internal/gitaly/hook/prereceive_test.go b/internal/gitaly/hook/prereceive_test.go index 095cd54c3..9dc589cbf 100644 --- a/internal/gitaly/hook/prereceive_test.go +++ b/internal/gitaly/hook/prereceive_test.go @@ -189,9 +189,10 @@ func TestPrereceive_quarantine(t *testing.T) { t, gitlab.MockAllowed, gitlab.MockPreReceive, gitlab.MockPostReceive, ), cfg) - script := fmt.Sprintf("#!/bin/sh\n%s cat-file -p '%s' || true\n", - cfg.Git.BinPath, blobID.String()) - gittest.WriteCustomHook(t, repoPath, "pre-receive", []byte(script)) + gittest.WriteCustomHook(t, repoPath, "pre-receive", []byte(fmt.Sprintf( + `#!/bin/sh + git cat-file -p '%s' || true + `, blobID.String()))) for repo, isQuarantined := range map[*gitalypb.Repository]bool{ quarantine.QuarantinedRepo(): true, |