Avoid modifying HOME environment during tests
Recent change 3b7e6f76 breaks version managers.
I suddenly started seeing errors like this when running Gitaly tests locally:
gitaly rs-divergent-refs-response % go test -timeout 30s gitlab.com/gitlab-org/gitaly/internal/service/remote -run '^(TestSuccessfulUpdateRemoteMirrorRequest)'
time="2020-04-10T14:29:37-05:00" level=warning msg="git path not configured. Using default path resolution" resolvedPath=/usr/local/bin/git
time="2020-04-10T14:29:37-05:00" level=warning msg="Gitaly bin directory is not configured" error="stat : no such file or directory"
time="2020-04-10T14:29:37-05:00" level=info msg="clearing disk cache object folder" path=/Users/rspeicher/Code/gitlab/gitaly/internal/testhelper/testdata/data
time="2020-04-10T14:29:37-05:00" level=info msg="moving disk cache object folder to /Users/rspeicher/Code/gitlab/gitaly/internal/testhelper/testdata/data/+gitaly/tmp/diskcache437698584" path=/Users/rspeicher/Code/gitlab/gitaly/internal/testhelper/testdata/data
time="2020-04-10T14:29:37-05:00" level=info msg="disk cache object folder doesn't exist, no need to remove" path=/Users/rspeicher/Code/gitlab/gitaly/internal/testhelper/testdata/data
time="2020-04-10T14:29:37-05:00" level=info msg="Starting file walker for /Users/rspeicher/Code/gitlab/gitaly/internal/testhelper/testdata/data/+gitaly/cache" path=/Users/rspeicher/Code/gitlab/gitaly/internal/testhelper/testdata/data/+gitaly/cache
time="2020-04-10T14:29:37-05:00" level=info msg="Starting file walker for /Users/rspeicher/Code/gitlab/gitaly/internal/testhelper/testdata/data/+gitaly/state" path=/Users/rspeicher/Code/gitlab/gitaly/internal/testhelper/testdata/data/+gitaly/state
unknown command: bundle. Perhaps you have to reshim?
time="2020-04-10T14:29:37-05:00" level=fatal msg="error configuring tests: exit status 1; stderr: \"\""
FAIL gitlab.com/gitlab-org/gitaly/internal/service/remote 0.561s
FAIL
The unknown command: bundle. Perhaps you have to reshim? error is from asdf, which I use to manage Ruby and Go versions, among others. By default it stores all versions in $HOME/.asdf.
3b7e6f76 recently updated to overwrite the ENV['HOME'] value, which breaks asdf and just seems like a troublesome idea in general.
I think a better option would be to use GIT_CONFIG:
GIT_CONFIG
Take the configuration from the given file instead of .git/config. Using the "--global" option forces this to ~/.gitconfig. Using the
"--system" option forces this to $(prefix)/etc/gitconfig.
Edited by Robert Speicher