Overwrite git global config and fix partial clone tests
Gitaly unit tests were using default git global config what makes them dependant on the environment. For example when GPG sign was enabled some tests were failing:
Gitlab::Git::Repository#squash with an ASCII-8BIT diff applies a ASCII-8BIT diff
Failure/Error: raise GitError, output unless status.zero?
Gitlab::Git::Repository::GitError:
error: gpg failed to sign the data
fatal: failed to write commit object
# ./lib/gitlab/git/repository.rb:773:in `run_git!'
# ./lib/gitlab/git/repository.rb:408:in `block in squash'
# ./lib/gitlab/git/repository.rb:894:in `with_worktree'
# ./lib/gitlab/git/repository.rb:399:in `squash'
# ./spec/lib/gitlab/git/repository_spec.rb:661:in `block (3 levels) in <top (required)>'
# ./spec/lib/gitlab/git/repository_spec.rb:744:in `block (4 levels) in <top (required)>'
Similiar think happened for all tests doing git commit
on both ruby and go parts.
The solution for that is to overwrite HOME
env variable since this is the only way to not use the user's gitconfig. In the go part also GOCACHE
have to be overwritten because it's by default derived from HOME
.
The second problem was that git cat-file -e
was used to check if object was fetched during a partial clone (Test TestUploadPackCloneWithPartialCloneFilter
). Remote for this repository was set to git@localhost:test/test.git
. This caused that git cat-file -e
tried to reach localhost
via ssh to fetch the missing object. It works fine for CI because there is nothing listening on port 22 but on my machine with sshd
running I got password prompt from ssh
. The solution for this is to set empty GIT_ALLOW_PROTOCOL
env variable and therefore forbid using ssh (or any other protocol) to fetch data from remote.