diff options
author | Sami Hiltunen <shiltunen@gitlab.com> | 2021-07-21 13:37:40 +0300 |
---|---|---|
committer | Sami Hiltunen <shiltunen@gitlab.com> | 2021-07-21 13:41:30 +0300 |
commit | 53fdadee6a593cb26d31a9220881ca47c341d0d0 (patch) | |
tree | 8705f9160ef958a769573e258b216951aedb4d2b | |
parent | f3fdf1a5a6b14cd5771c9d2af19d7cd3aebad5bc (diff) |
Fix mirroring empty repository in UpdateRemoteMirrorsmh-fix-master-notice
UpdateRemoteMirror's Ruby implementation did not handle the case when
there were no branches in the repository that source repository when
mirroring and failed when trying to access its default branch. The RPC
then failed with a NoMethodError when trying to invoke a method on a
Nil object. The Go implementation matched the behavior to pass the existing
tests. Now that the Go implementation is enabled always, we can drop
this behavior and allow the repository mirroring to work even if there
are no branches in the source repository.
Changelog: fixed
-rw-r--r-- | internal/gitaly/service/remote/update_remote_mirror.go | 5 | ||||
-rw-r--r-- | internal/gitaly/service/remote/update_remote_mirror_test.go | 6 |
2 files changed, 3 insertions, 8 deletions
diff --git a/internal/gitaly/service/remote/update_remote_mirror.go b/internal/gitaly/service/remote/update_remote_mirror.go index cc9211c26..ff884fce6 100644 --- a/internal/gitaly/service/remote/update_remote_mirror.go +++ b/internal/gitaly/service/remote/update_remote_mirror.go @@ -106,11 +106,6 @@ func (s *server) updateRemoteMirror(stream gitalypb.RemoteService_UpdateRemoteMi return fmt.Errorf("get local references: %w", err) } - if len(localRefs) == 0 { - // https://gitlab.com/gitlab-org/gitaly/-/issues/3503 - return errors.New("close stream to gitaly-ruby: rpc error: code = Unknown desc = NoMethodError: undefined method `id' for nil:NilClass") - } - defaultBranch, err := ref.DefaultBranchName(ctx, repo) if err != nil { return fmt.Errorf("get default branch: %w", err) diff --git a/internal/gitaly/service/remote/update_remote_mirror_test.go b/internal/gitaly/service/remote/update_remote_mirror_test.go index 52e41da5c..3dde9a173 100644 --- a/internal/gitaly/service/remote/update_remote_mirror_test.go +++ b/internal/gitaly/service/remote/update_remote_mirror_test.go @@ -59,12 +59,12 @@ func TestUpdateRemoteMirror(t *testing.T) { expectedMirrorRefs map[string]string }{ { - // https://gitlab.com/gitlab-org/gitaly/-/issues/3503 - desc: "empty mirror source fails", + desc: "empty mirror source works", mirrorRefs: refs{ "refs/heads/tags": {"commit 1"}, }, - errorContains: "rpc error: code = Internal desc = close stream to gitaly-ruby: rpc error: code = Unknown desc = NoMethodError: undefined method `id' for nil:NilClass", + response: &gitalypb.UpdateRemoteMirrorResponse{}, + expectedMirrorRefs: map[string]string{}, }, { desc: "mirror is up to date", |