From b2928d5d41903f9287cece78d51103e30be2ee2f Mon Sep 17 00:00:00 2001 From: Robert Speicher Date: Wed, 12 Feb 2020 16:15:48 -0600 Subject: [PATCH 1/7] Add delete_divergent_refs to UpdateRemoteMirrorRequest protocol --- proto/go/gitalypb/remote.pb.go | 104 ++++++++++++++++++--------------- proto/remote.proto | 1 + ruby/proto/gitaly/remote_pb.rb | 1 + 3 files changed, 59 insertions(+), 47 deletions(-) diff --git a/proto/go/gitalypb/remote.pb.go b/proto/go/gitalypb/remote.pb.go index 8ec9bdc309..6b09640a5a 100644 --- a/proto/go/gitalypb/remote.pb.go +++ b/proto/go/gitalypb/remote.pb.go @@ -297,6 +297,7 @@ type UpdateRemoteMirrorRequest struct { OnlyBranchesMatching [][]byte `protobuf:"bytes,3,rep,name=only_branches_matching,json=onlyBranchesMatching,proto3" json:"only_branches_matching,omitempty"` SshKey string `protobuf:"bytes,4,opt,name=ssh_key,json=sshKey,proto3" json:"ssh_key,omitempty"` KnownHosts string `protobuf:"bytes,5,opt,name=known_hosts,json=knownHosts,proto3" json:"known_hosts,omitempty"` + DeleteDivergentRefs bool `protobuf:"varint,6,opt,name=delete_divergent_refs,json=deleteDivergentRefs,proto3" json:"delete_divergent_refs,omitempty"` XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_unrecognized []byte `json:"-"` XXX_sizecache int32 `json:"-"` @@ -362,6 +363,13 @@ func (m *UpdateRemoteMirrorRequest) GetKnownHosts() string { return "" } +func (m *UpdateRemoteMirrorRequest) GetDeleteDivergentRefs() bool { + if m != nil { + return m.DeleteDivergentRefs + } + return false +} + type UpdateRemoteMirrorResponse struct { XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_unrecognized []byte `json:"-"` @@ -713,53 +721,55 @@ func init() { func init() { proto.RegisterFile("remote.proto", fileDescriptor_eefc82927d57d89b) } var fileDescriptor_eefc82927d57d89b = []byte{ - // 732 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x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of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x56, 0xcb, 0x6e, 0xd3, 0x4a, + 0x18, 0x96, 0x93, 0x34, 0x97, 0x3f, 0xe9, 0x51, 0x3a, 0xe9, 0xe9, 0x71, 0x9c, 0x4a, 0x27, 0xf5, + 0x39, 0x48, 0x5e, 0xd0, 0xa4, 0x0a, 0x17, 0xb1, 0x40, 0x42, 0x54, 0x08, 0x95, 0x4b, 0x2b, 0x30, + 0x74, 0xc3, 0xc6, 0x38, 0xc9, 0x9f, 0xc4, 0xaa, 0xe3, 0x09, 0x33, 0x4e, 0x21, 0xef, 0x81, 0x54, + 0x16, 0xbc, 0x00, 0x1b, 0x1e, 0x83, 0x87, 0xea, 0x0a, 0x8d, 0x67, 0x9c, 0x38, 0xad, 0x13, 0x16, + 0x85, 0x9d, 0xe7, 0xfb, 0x6f, 0xdf, 0x7f, 0x95, 0xa1, 0xc2, 0x70, 0x4c, 0x43, 0x6c, 0x4d, 0x18, + 0x0d, 0x29, 0xc9, 0x0f, 0xbd, 0xd0, 0xf5, 0x67, 0x46, 0x85, 0x8f, 0x5c, 0x86, 0x7d, 0x89, 0x9a, + 0xdf, 0x35, 0xa8, 0x3e, 0xee, 0xf7, 0xed, 0x48, 0xd3, 0xc6, 0x0f, 0x53, 0xe4, 0x21, 0x79, 0x00, + 0xc0, 0x70, 0x42, 0xb9, 0x17, 0x52, 0x36, 0xd3, 0xb5, 0xa6, 0x66, 0x95, 0x3b, 0xa4, 0x25, 0xed, + 0x5b, 0xf6, 0x5c, 0x72, 0x98, 0xfb, 0xf2, 0xe3, 0xb6, 0x66, 0x27, 0x74, 0x09, 0x81, 0x5c, 0xe0, + 0x8e, 0x51, 0xcf, 0x34, 0x35, 0xab, 0x64, 0x47, 0xdf, 0xa4, 0x0a, 0xd9, 0x29, 0xf3, 0xf5, 0x6c, + 0x04, 0x89, 0x4f, 0x72, 0x0b,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69, 0xdd, 0x8e, 0xfe, 0x16, 0xda, 0x43, + 0xaa, 0xde, 0x93, 0x6e, 0x37, 0x1f, 0x41, 0x77, 0x7e, 0x06, 0x00, 0x00, 0xff, 0xff, 0xb1, 0x4b, + 0x17, 0xbc, 0x66, 0x08, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. diff --git a/proto/remote.proto b/proto/remote.proto index f4fd61f3e1..56999feb47 100644 --- a/proto/remote.proto +++ b/proto/remote.proto @@ -83,6 +83,7 @@ message UpdateRemoteMirrorRequest { repeated bytes only_branches_matching = 3; string ssh_key = 4; string known_hosts = 5; + bool delete_divergent_refs = 6; } message UpdateRemoteMirrorResponse {} diff --git a/ruby/proto/gitaly/remote_pb.rb b/ruby/proto/gitaly/remote_pb.rb index 48c51650e5..892620a83a 100644 --- a/ruby/proto/gitaly/remote_pb.rb +++ b/ruby/proto/gitaly/remote_pb.rb @@ -33,6 +33,7 @@ Google::Protobuf::DescriptorPool.generated_pool.build do repeated :only_branches_matching, :bytes, 3 optional :ssh_key, :string, 4 optional :known_hosts, :string, 5 + optional :delete_divergent_refs, :bool, 6 end add_message "gitaly.UpdateRemoteMirrorResponse" do end -- GitLab From 3ac86dca75cec658ee6f15515426e1fe1c9fa0f0 Mon Sep 17 00:00:00 2001 From: Robert Speicher Date: Thu, 13 Feb 2020 14:10:38 -0600 Subject: [PATCH 2/7] Optionally delete divergent refs when mirroring This updates RemoteService and RemoteMirror to take a `delete_divergent_refs` parameter which defaults to `true` (the current behavior), and allows disabling the behavior on a per-mirror basis. The option will be provided by the client and will be behind a feature flag there. --- ruby/lib/gitaly_server/remote_service.rb | 8 ++++---- ruby/lib/gitlab/git/remote_mirror.rb | 7 +++++-- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/ruby/lib/gitaly_server/remote_service.rb b/ruby/lib/gitaly_server/remote_service.rb index 39cc6e60e0..e232ae7fdb 100644 --- a/ruby/lib/gitaly_server/remote_service.rb +++ b/ruby/lib/gitaly_server/remote_service.rb @@ -24,16 +24,16 @@ module GitalyServer def update_remote_mirror(call) request_enum = call.each_remote_read first_request = request_enum.next - repo = Gitlab::Git::Repository.from_gitaly(first_request.repository, call) - only_branches_matching = first_request.only_branches_matching.to_a + only_branches_matching = first_request.only_branches_matching.to_a only_branches_matching += request_enum.flat_map(&:only_branches_matching) remote_mirror = Gitlab::Git::RemoteMirror.new( - repo, + Gitlab::Git::Repository.from_gitaly(first_request.repository, call), first_request.ref_name, + ssh_auth: Gitlab::Git::SshAuth.from_gitaly(first_request), only_branches_matching: only_branches_matching, - ssh_auth: Gitlab::Git::SshAuth.from_gitaly(first_request) + delete_divergent_refs: first_request.delete_divergent_refs ) remote_mirror.update diff --git a/ruby/lib/gitlab/git/remote_mirror.rb b/ruby/lib/gitlab/git/remote_mirror.rb index f1f110dfb3..1380c3930b 100644 --- a/ruby/lib/gitlab/git/remote_mirror.rb +++ b/ruby/lib/gitlab/git/remote_mirror.rb @@ -3,11 +3,12 @@ module Gitlab class RemoteMirror attr_reader :repository, :remote_name, :ssh_auth, :only_branches_matching - def initialize(repository, remote_name, ssh_auth:, only_branches_matching: []) + def initialize(repository, remote_name, ssh_auth:, only_branches_matching: [], delete_divergent_refs: true) @repository = repository @remote_name = remote_name @ssh_auth = ssh_auth @only_branches_matching = only_branches_matching + @delete_divergent_refs = delete_divergent_refs end def update @@ -81,6 +82,8 @@ module Gitlab end def delete_refs(local_refs, remote_refs, env:) + return unless @delete_divergent_refs + refs = refs_to_delete(local_refs, remote_refs) return unless refs.present? @@ -96,7 +99,7 @@ module Gitlab remote_ref_id = remote_ref.dereferenced_target.try(:id) - remote_ref_id && repository.ancestor?(remote_ref_id, default_branch_id) + repository.ancestor?(remote_ref_id, default_branch_id) end end -- GitLab From a9999cf3920fb270ac1d900a4e68d86fe379f89c Mon Sep 17 00:00:00 2001 From: Robert Speicher Date: Thu, 13 Feb 2020 15:12:43 -0600 Subject: [PATCH 3/7] Invert delete_divergent_refs to keep_divergent_refs We can't have a boolean field default to `true`, so we were breaking current behavior. The simplest solution was to invert the option, which we've done here. --- proto/go/gitalypb/remote.pb.go | 104 +++++++++++------------ proto/remote.proto | 2 +- ruby/lib/gitaly_server/remote_service.rb | 2 +- ruby/lib/gitlab/git/remote_mirror.rb | 6 +- ruby/proto/gitaly/remote_pb.rb | 2 +- 5 files changed, 58 insertions(+), 58 deletions(-) diff --git a/proto/go/gitalypb/remote.pb.go b/proto/go/gitalypb/remote.pb.go index 6b09640a5a..35119836a6 100644 --- a/proto/go/gitalypb/remote.pb.go +++ b/proto/go/gitalypb/remote.pb.go @@ -297,7 +297,7 @@ type UpdateRemoteMirrorRequest struct { OnlyBranchesMatching [][]byte `protobuf:"bytes,3,rep,name=only_branches_matching,json=onlyBranchesMatching,proto3" json:"only_branches_matching,omitempty"` SshKey string `protobuf:"bytes,4,opt,name=ssh_key,json=sshKey,proto3" json:"ssh_key,omitempty"` KnownHosts string `protobuf:"bytes,5,opt,name=known_hosts,json=knownHosts,proto3" json:"known_hosts,omitempty"` - DeleteDivergentRefs bool `protobuf:"varint,6,opt,name=delete_divergent_refs,json=deleteDivergentRefs,proto3" json:"delete_divergent_refs,omitempty"` + KeepDivergentRefs bool `protobuf:"varint,6,opt,name=keep_divergent_refs,json=keepDivergentRefs,proto3" json:"keep_divergent_refs,omitempty"` XXX_NoUnkeyedLiteral struct{} `json:"-"` XXX_unrecognized []byte `json:"-"` XXX_sizecache int32 `json:"-"` @@ -363,9 +363,9 @@ func (m *UpdateRemoteMirrorRequest) GetKnownHosts() string { return "" } -func (m *UpdateRemoteMirrorRequest) GetDeleteDivergentRefs() bool { +func (m *UpdateRemoteMirrorRequest) GetKeepDivergentRefs() bool { if m != nil { - return m.DeleteDivergentRefs + return m.KeepDivergentRefs } return false } @@ -721,55 +721,55 @@ func init() { func init() { proto.RegisterFile("remote.proto", fileDescriptor_eefc82927d57d89b) } var fileDescriptor_eefc82927d57d89b = []byte{ - // 758 bytes of a gzipped FileDescriptorProto - 0x1f, 0x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0x51, 0xe6, 0x30, 0x1c, 0x8c, 0xdd, 0x09, - 0xd7, 0x37, 0x9a, 0x59, 0xab, 0x64, 0x6f, 0x4a, 0xd4, 0x96, 0xe0, 0xf3, 0x5c, 0x31, 0x57, 0xdd, - 0x88, 0x41, 0xa5, 0x6a, 0xd6, 0x60, 0x2b, 0xc1, 0x97, 0x4f, 0x68, 0xc0, 0xd1, 0xec, 0x41, 0x4d, - 0x20, 0xe7, 0xf8, 0x07, 0xf3, 0x30, 0x5b, 0xb0, 0xbd, 0x1c, 0x44, 0x06, 0x27, 0x3b, 0x90, 0x67, - 0xc8, 0xa7, 0x7e, 0x18, 0x45, 0x28, 0xda, 0xea, 0x65, 0x5e, 0x68, 0x60, 0x3c, 0xc5, 0xb0, 0x37, - 0x7a, 0x16, 0x84, 0xc8, 0x02, 0xd7, 0xff, 0x5d, 0xe4, 0x1e, 0xc1, 0x96, 0xec, 0xac, 0x93, 0x70, - 0x90, 0x59, 0xe5, 0xc0, 0xae, 0x32, 0x15, 0x37, 0x46, 0xcc, 0x7b, 0xd0, 0x48, 0x25, 0xf6, 0x8b, - 0x84, 0x3e, 0x67, 0xa0, 0x7e, 0x3a, 0xe9, 0xbb, 0xa1, 0xaa, 0xc0, 0xb1, 0xea, 0xd6, 0x4d, 0xf3, - 0xa9, 0x43, 0x91, 0xe1, 0xc0, 0x49, 0x14, 0xbc, 0xc0, 0x70, 0x70, 0x22, 0x66, 0xe7, 0x2e, 0xec, - 0xd0, 0xc0, 0x9f, 0x39, 0x5d, 0xe6, 0x06, 0xbd, 0x11, 0x72, 0x67, 0xec, 0x86, 0xbd, 0x91, 0x17, - 0x0c, 0xf5, 0x6c, 0x33, 0x6b, 0x55, 0xec, 0x6d, 0x21, 0x3d, 0x54, 0xc2, 0x63, 0x25, 0x23, 0xff, - 0x40, 0x81, 0xf3, 0x91, 0x73, 0x86, 0x33, 0x3d, 0x17, 0xf9, 0xcb, 0x73, 0x3e, 0x7a, 0x81, 0x33, - 0xf2, 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 0xda, 0x43, - 0xaa, 0xde, 0x93, 0x6e, 0x37, 0x1f, 0x41, 0x77, 0x7e, 0x06, 0x00, 0x00, 0xff, 0xff, 0xb1, 0x4b, - 0x17, 0xbc, 0x66, 0x08, 0x00, 0x00, + // 753 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x56, 0xc9, 0x6e, 0xd3, 0x40, + 0x18, 0x96, 0x93, 0x34, 0xcb, 0x9f, 0x14, 0x25, 0x93, 0xaa, 0x38, 0x4e, 0x25, 0x52, 0x03, 0x92, + 0x0f, 0x34, 0xa9, 0xca, 0x22, 0x0e, 0x48, 0x88, 0x0a, 0xa1, 0xb2, 0xb4, 0x02, 0x43, 0x2f, 0x5c, + 0x8c, 0x93, 0x8c, 0x63, 0x2b, 0x8e, 0xc7, 0xcc, 0x38, 0x85, 0xbc, 0x05, 0xb7, 0x72, 0xe0, 0x05, + 0xb8, 0xf0, 0x18, 0x3c, 0x54, 0x4f, 0x68, 0x3c, 0xe3, 0xc4, 0x69, 0x9d, 0x70, 0x28, 0xdc, 0x3c, + 0xdf, 0xbf, 0x7d, 0xff, 0x2a, 0x43, 0x8d, 0xe2, 0x09, 0x89, 0x70, 0x37, 0xa4, 0x24, 0x22, 0xa8, + 0x38, 0xf2, 0x22, 0xdb, 0x9f, 0x69, 0x35, 0xe6, 0xda, 0x14, 0x0f, 0x05, 0xaa, 0xff, 0x52, 0xa0, + 0xfe, 0x6c, 0x38, 0x34, 0x63, 0x4d, 0x13, 0x7f, 0x9e, 0x62, 0x16, 0xa1, 0xc7, 0x00, 0x14, 0x87, + 0x84, 0x79, 0x11, 0xa1, 0x33, 0x55, 0xe9, 0x28, 0x46, 0xf5, 0x00, 0x75, 0x85, 0x7d, 0xd7, 0x9c, + 0x4b, 0x0e, 0x0b, 0xdf, 0x7f, 0xdf, 0x53, 0xcc, 0x94, 0x2e, 0x42, 0x50, 0x08, 0x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f, 0xbe, 0x72, 0xb8, 0xff, 0x91, 0xeb, 0xf9, 0x76, 0xbf, 0x3b, 0x20, 0x93, 0x9e, 0xf8, + 0xdc, 0x23, 0x74, 0xd4, 0x13, 0xd6, 0xbd, 0xf8, 0x4f, 0xa1, 0x37, 0x22, 0xf2, 0x1d, 0xf6, 0xfb, + 0xc5, 0x18, 0xba, 0xff, 0x27, 0x00, 0x00, 0xff, 0xff, 0x84, 0x8d, 0xa5, 0xca, 0x62, 0x08, 0x00, + 0x00, } // Reference imports to suppress errors if they are not otherwise used. diff --git a/proto/remote.proto b/proto/remote.proto index 56999feb47..2f7970c89a 100644 --- a/proto/remote.proto +++ b/proto/remote.proto @@ -83,7 +83,7 @@ message UpdateRemoteMirrorRequest { repeated bytes only_branches_matching = 3; string ssh_key = 4; string known_hosts = 5; - bool delete_divergent_refs = 6; + bool keep_divergent_refs = 6; } message UpdateRemoteMirrorResponse {} diff --git a/ruby/lib/gitaly_server/remote_service.rb b/ruby/lib/gitaly_server/remote_service.rb index e232ae7fdb..fa62ec0925 100644 --- a/ruby/lib/gitaly_server/remote_service.rb +++ b/ruby/lib/gitaly_server/remote_service.rb @@ -33,7 +33,7 @@ module GitalyServer first_request.ref_name, ssh_auth: Gitlab::Git::SshAuth.from_gitaly(first_request), only_branches_matching: only_branches_matching, - delete_divergent_refs: first_request.delete_divergent_refs + keep_divergent_refs: first_request.keep_divergent_refs ) remote_mirror.update diff --git a/ruby/lib/gitlab/git/remote_mirror.rb b/ruby/lib/gitlab/git/remote_mirror.rb index 1380c3930b..1d0ef7cec4 100644 --- a/ruby/lib/gitlab/git/remote_mirror.rb +++ b/ruby/lib/gitlab/git/remote_mirror.rb @@ -3,12 +3,12 @@ module Gitlab class RemoteMirror attr_reader :repository, :remote_name, :ssh_auth, :only_branches_matching - def initialize(repository, remote_name, ssh_auth:, only_branches_matching: [], delete_divergent_refs: true) + def initialize(repository, remote_name, ssh_auth:, only_branches_matching: [], keep_divergent_refs: true) @repository = repository @remote_name = remote_name @ssh_auth = ssh_auth @only_branches_matching = only_branches_matching - @delete_divergent_refs = delete_divergent_refs + @keep_divergent_refs = keep_divergent_refs end def update @@ -82,7 +82,7 @@ module Gitlab end def delete_refs(local_refs, remote_refs, env:) - return unless @delete_divergent_refs + return if @keep_divergent_refs refs = refs_to_delete(local_refs, remote_refs) diff --git a/ruby/proto/gitaly/remote_pb.rb b/ruby/proto/gitaly/remote_pb.rb index 892620a83a..770f5e4e88 100644 --- a/ruby/proto/gitaly/remote_pb.rb +++ b/ruby/proto/gitaly/remote_pb.rb @@ -33,7 +33,7 @@ Google::Protobuf::DescriptorPool.generated_pool.build do repeated :only_branches_matching, :bytes, 3 optional :ssh_key, :string, 4 optional :known_hosts, :string, 5 - optional :delete_divergent_refs, :bool, 6 + optional :keep_divergent_refs, :bool, 6 end add_message "gitaly.UpdateRemoteMirrorResponse" do end -- GitLab From 726d9446ec21c92fe99e7d74ba9e21dc7ca1ac19 Mon Sep 17 00:00:00 2001 From: Robert Speicher Date: Thu, 13 Feb 2020 16:57:36 -0600 Subject: [PATCH 4/7] Add changelog for "Keep divergent refs" --- changelogs/unreleased/rs-delete-divergent-refs-option.yml | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 changelogs/unreleased/rs-delete-divergent-refs-option.yml diff --git a/changelogs/unreleased/rs-delete-divergent-refs-option.yml b/changelogs/unreleased/rs-delete-divergent-refs-option.yml new file mode 100644 index 0000000000..9e4187cae9 --- /dev/null +++ b/changelogs/unreleased/rs-delete-divergent-refs-option.yml @@ -0,0 +1,5 @@ +--- +title: Optionally keep divergent refs when mirroring +merge_request: 1828 +author: +type: added -- GitLab From 6c80b3af27a415bc3f1800c471847b31675d464e Mon Sep 17 00:00:00 2001 From: Robert Speicher Date: Thu, 13 Feb 2020 17:17:43 -0600 Subject: [PATCH 5/7] Fix default value for keep_divergent_refs --- ruby/lib/gitlab/git/remote_mirror.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ruby/lib/gitlab/git/remote_mirror.rb b/ruby/lib/gitlab/git/remote_mirror.rb index 1d0ef7cec4..998095ee51 100644 --- a/ruby/lib/gitlab/git/remote_mirror.rb +++ b/ruby/lib/gitlab/git/remote_mirror.rb @@ -3,7 +3,7 @@ module Gitlab class RemoteMirror attr_reader :repository, :remote_name, :ssh_auth, :only_branches_matching - def initialize(repository, remote_name, ssh_auth:, only_branches_matching: [], keep_divergent_refs: true) + def initialize(repository, remote_name, ssh_auth:, only_branches_matching: [], keep_divergent_refs: false) @repository = repository @remote_name = remote_name @ssh_auth = ssh_auth -- GitLab From ee665bbf2f575b2c3e968f2dc0af727895794d71 Mon Sep 17 00:00:00 2001 From: Robert Speicher Date: Fri, 14 Feb 2020 15:19:20 -0600 Subject: [PATCH 6/7] Add test case for KeepDivergentRefs --- .../remote/update_remote_mirror_test.go | 56 +++++++++++++++++++ 1 file changed, 56 insertions(+) diff --git a/internal/service/remote/update_remote_mirror_test.go b/internal/service/remote/update_remote_mirror_test.go index cf6823c6f4..87e51eb8cd 100644 --- a/internal/service/remote/update_remote_mirror_test.go +++ b/internal/service/remote/update_remote_mirror_test.go @@ -172,6 +172,62 @@ func TestSuccessfulUpdateRemoteMirrorRequestWithWildcards(t *testing.T) { require.NotContains(t, mirrorRefs, "refs/tags/v1.2.0") } +func TestSuccessfulUpdateRemoteMirrorRequestWithKeepDivergentRefs(t *testing.T) { + server, serverSocketPath := runRemoteServiceServer(t) + defer server.Stop() + + client, conn := NewRemoteClient(t, serverSocketPath) + defer conn.Close() + + testRepo, testRepoPath, cleanupFn := testhelper.NewTestRepo(t) + defer cleanupFn() + + _, mirrorPath, mirrorCleanupFn := testhelper.NewTestRepo(t) + defer mirrorCleanupFn() + + remoteName := "remote_mirror_1" + + testhelper.CreateTag(t, mirrorPath, "v2.0.0", "master", nil) + + setupCommands := [][]string{ + // Preconditions + {"config", "user.email", "gitalytest@example.com"}, + {"remote", "add", remoteName, mirrorPath}, + {"fetch", remoteName}, + + // Delete a branch and a tag to ensure they're kept around in the mirror + {"branch", "-D", "not-merged-branch"}, + {"tag", "-d", "v2.0.0"}, + } + + for _, args := range setupCommands { + gitArgs := []string{"-C", testRepoPath} + gitArgs = append(gitArgs, args...) + testhelper.MustRunCommand(t, nil, "git", gitArgs...) + } + + ctx, cancel := testhelper.Context() + defer cancel() + + firstRequest := &gitalypb.UpdateRemoteMirrorRequest{ + Repository: testRepo, + RefName: remoteName, + KeepDivergentRefs: true, + } + + stream, err := client.UpdateRemoteMirror(ctx) + require.NoError(t, err) + require.NoError(t, stream.Send(firstRequest)) + + _, err = stream.CloseAndRecv() + require.NoError(t, err) + + mirrorRefs := string(testhelper.MustRunCommand(t, nil, "git", "-C", mirrorPath, "for-each-ref")) + + require.Contains(t, mirrorRefs, "refs/heads/not-merged-branch") + require.Contains(t, mirrorRefs, "refs/tags/v2.0.0") +} + func TestFailedUpdateRemoteMirrorRequestDueToValidation(t *testing.T) { server, serverSocketPath := runRemoteServiceServer(t) defer server.Stop() -- GitLab From b03cf0b16353266ec35b00c049e93e5c06649ce2 Mon Sep 17 00:00:00 2001 From: Robert Speicher Date: Wed, 19 Feb 2020 10:57:39 -0600 Subject: [PATCH 7/7] Make all RemoteMirror arguments required --- ruby/lib/gitlab/git/remote_mirror.rb | 2 +- ruby/spec/lib/gitlab/git/remote_mirror_spec.rb | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/ruby/lib/gitlab/git/remote_mirror.rb b/ruby/lib/gitlab/git/remote_mirror.rb index 998095ee51..9311a8b256 100644 --- a/ruby/lib/gitlab/git/remote_mirror.rb +++ b/ruby/lib/gitlab/git/remote_mirror.rb @@ -3,7 +3,7 @@ module Gitlab class RemoteMirror attr_reader :repository, :remote_name, :ssh_auth, :only_branches_matching - def initialize(repository, remote_name, ssh_auth:, only_branches_matching: [], keep_divergent_refs: false) + def initialize(repository, remote_name, ssh_auth:, only_branches_matching:, keep_divergent_refs:) @repository = repository @remote_name = remote_name @ssh_auth = ssh_auth diff --git a/ruby/spec/lib/gitlab/git/remote_mirror_spec.rb b/ruby/spec/lib/gitlab/git/remote_mirror_spec.rb index 34503d0b08..2b7bc06051 100644 --- a/ruby/spec/lib/gitlab/git/remote_mirror_spec.rb +++ b/ruby/spec/lib/gitlab/git/remote_mirror_spec.rb @@ -18,7 +18,8 @@ describe Gitlab::Git::RemoteMirror do repository, ref_name, ssh_auth: ssh_auth, - only_branches_matching: [] + only_branches_matching: [], + keep_divergent_refs: false ) end @@ -33,7 +34,8 @@ describe Gitlab::Git::RemoteMirror do repository, ref_name, ssh_auth: ssh_auth, - only_branches_matching: ['master', '*-stable'] + only_branches_matching: ['master', '*-stable'], + keep_divergent_refs: false ) end -- GitLab