Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitaly.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZeger-Jan van de Weg <git@zjvandeweg.nl>2021-05-11 17:07:58 +0300
committerZeger-Jan van de Weg <git@zjvandeweg.nl>2021-05-11 17:07:58 +0300
commit4b444642ec66081e7b13bd0ce71ae4c191327991 (patch)
tree7dbd1aee9eba108b10d034ed11e619a819011df9
parent8955b31698a0f37800294938fcac1fdfe029642c (diff)
parent97930aa7585016cb9b0325c6fe1869fcedff5782 (diff)
Merge branch 'smh-fix-unprotected-branch-mirroring' into 'master'
Ignore diverged non-matched branches in UpdateRemoteMirror Go port See merge request gitlab-org/gitaly!3472
-rw-r--r--internal/gitaly/service/remote/update_remote_mirror.go7
-rw-r--r--internal/gitaly/service/remote/update_remote_mirror_test.go18
2 files changed, 24 insertions, 1 deletions
diff --git a/internal/gitaly/service/remote/update_remote_mirror.go b/internal/gitaly/service/remote/update_remote_mirror.go
index cee8cad53..05e5a782c 100644
--- a/internal/gitaly/service/remote/update_remote_mirror.go
+++ b/internal/gitaly/service/remote/update_remote_mirror.go
@@ -160,7 +160,12 @@ func (s *server) goUpdateRemoteMirror(stream gitalypb.RemoteService_UpdateRemote
if !isAncestor {
// The mirror's reference has diverged from the local ref, or the mirror contains a commit
// which is not present in the local repository.
- divergentRefs = append(divergentRefs, []byte(localRef.Name))
+ if referenceMatcher.MatchString(localRef.Name.String()) {
+ // diverged branches on the mirror are only included in the response if they match
+ // one of the branches in the selector
+ divergentRefs = append(divergentRefs, []byte(localRef.Name))
+ }
+
delete(remoteRefs, localRef.Name)
continue
}
diff --git a/internal/gitaly/service/remote/update_remote_mirror_test.go b/internal/gitaly/service/remote/update_remote_mirror_test.go
index f5d959069..9f02f964b 100644
--- a/internal/gitaly/service/remote/update_remote_mirror_test.go
+++ b/internal/gitaly/service/remote/update_remote_mirror_test.go
@@ -137,6 +137,24 @@ func testUpdateRemoteMirrorFeatured(t *testing.T, ctx context.Context, cfg confi
},
},
{
+ desc: "ignores diverged branches not matched by the branch selector",
+ sourceRefs: refs{
+ "refs/heads/matched": {"commit 1"},
+ "refs/heads/diverged": {"commit 1"},
+ },
+ onlyBranchesMatching: []string{"matched"},
+ keepDivergentRefs: true,
+ mirrorRefs: refs{
+ "refs/heads/matched": {"commit 1"},
+ "refs/heads/diverged": {"commit 2"},
+ },
+ response: &gitalypb.UpdateRemoteMirrorResponse{},
+ expectedMirrorRefs: map[string]string{
+ "refs/heads/matched": "commit 1",
+ "refs/heads/diverged": "commit 2",
+ },
+ },
+ {
desc: "does not delete refs with KeepDivergentRefs",
sourceRefs: refs{
"refs/heads/master": {"commit 1"},