diff options
author | Zeger-Jan van de Weg <git@zjvandeweg.nl> | 2019-07-12 10:49:24 +0300 |
---|---|---|
committer | Zeger-Jan van de Weg <git@zjvandeweg.nl> | 2019-07-12 11:06:18 +0300 |
commit | 0dd443615adf3b11c27b421edf350b141e2307c7 (patch) | |
tree | 7ca3da2fbbde2570854a77e01fcc96189aa60b65 | |
parent | 47655b4df3bf9987c576edd2f808554606054bd9 (diff) |
Allow explicit missing ref error in tests
In https://gitlab.com/gitlab-org/git/commit/014ade748420b074a06dbb7f5fb974b5e6184f4
the behaviour of upload-pack changed to be explicit about missing refs.
In the Gitaly test the assertion was made against the output of the
command being empty. This is no longer the case, so now an assertion is
made against the output.
This itself might break in the furture, but given the test is about hidden
refs it's probably better to have this test break somewhere in the
future than remove the assertion or weaken it.
-rw-r--r-- | README.md | 2 | ||||
-rw-r--r-- | changelogs/unreleased/zj-bump-git-version-test-matrix.yml | 5 | ||||
-rw-r--r-- | internal/git/proto.go | 13 | ||||
-rw-r--r-- | internal/service/smarthttp/upload_pack_test.go | 9 |
4 files changed, 27 insertions, 2 deletions
@@ -58,7 +58,7 @@ Gitaly requires Go 1.11.4 or newer and Ruby 2.5. Run `make` to download and compile Ruby dependencies, and to compile the Gitaly Go executable. -Gitaly uses `git`. Version `2.21.0` or higher is required. +Gitaly uses `git`. Versions `2.21.0` and `2.22.0` are supported. ## Configuration diff --git a/changelogs/unreleased/zj-bump-git-version-test-matrix.yml b/changelogs/unreleased/zj-bump-git-version-test-matrix.yml new file mode 100644 index 000000000..368737655 --- /dev/null +++ b/changelogs/unreleased/zj-bump-git-version-test-matrix.yml @@ -0,0 +1,5 @@ +--- +title: Add support for Git 2.22 +merge_request: 1359 +author: +type: added diff --git a/internal/git/proto.go b/internal/git/proto.go index dfe112311..5244e6bdb 100644 --- a/internal/git/proto.go +++ b/internal/git/proto.go @@ -148,6 +148,19 @@ func SupportsDeltaIslands(versionStr string) (bool, error) { return !versionLessThan(v, version{2, 20, 0}), nil } +// NoMissingWantErrMessage checks if the git version is before Git 2.22, +// in which versions the missing objects in the wants didn't yield an explicit +// error message, but no ouput at all. +func NoMissingWantErrMessage() bool { + ver, err := Version() + if err != nil { + return false + } + + lt, err := VersionLessThan(ver, "2.22.0") + return err == nil && lt +} + // BuildGitOptions helps to generate options to the git command. // If gitOpts is not empty then its values are passed as part of // the "-c" option of the git command, the other values are passed along with the subcommand. diff --git a/internal/service/smarthttp/upload_pack_test.go b/internal/service/smarthttp/upload_pack_test.go index a4a496c83..07dad6531 100644 --- a/internal/service/smarthttp/upload_pack_test.go +++ b/internal/service/smarthttp/upload_pack_test.go @@ -144,7 +144,14 @@ func TestUploadPackRequestWithGitConfigOptions(t *testing.T) { rpcRequest.GitConfigOptions = []string{"uploadpack.hideRefs=refs/hidden"} response, err = makePostUploadPackRequest(t, serverSocketPath, rpcRequest, requestBodyCopy) testhelper.RequireGrpcError(t, err, codes.Unavailable) - assert.Equal(t, response.String(), "", "Ref is hidden so no response should be received") + + // Remove the if clause if support is dropped for Git versions before 2.22 + if git.NoMissingWantErrMessage() { + assert.Equal(t, "", response.String(), "Ref is hidden so no response should be received") + } else { + expected := fmt.Sprintf("0049ERR upload-pack: not our ref %v", want) + assert.Equal(t, expected, response.String(), "Ref is hidden, expected error message did not appear") + } } func TestUploadPackRequestWithGitProtocol(t *testing.T) { |