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:
authorPaul Okstad <pokstad@gitlab.com>2020-09-26 01:06:41 +0300
committerPaul Okstad <pokstad@gitlab.com>2020-09-26 01:06:41 +0300
commitbb061a39e7fac36a9a8a145b06e653ef9b25178f (patch)
treede5e44c630edbe99af47066426141232173a8046
parentf4922bb91de88ffb476a06bba15b7828f25fe127 (diff)
parente34484a82e54e7e8a3894909a44d238f60b71ce4 (diff)
Merge branch 'sh-remote-branch-load-first' into 'master'
Ensure local branches are current when syncing remote mirrors See merge request gitlab-org/gitaly!2606
-rw-r--r--changelogs/unreleased/sh-remote-branch-load-first.yml5
-rw-r--r--ruby/lib/gitlab/git/remote_mirror.rb5
2 files changed, 9 insertions, 1 deletions
diff --git a/changelogs/unreleased/sh-remote-branch-load-first.yml b/changelogs/unreleased/sh-remote-branch-load-first.yml
new file mode 100644
index 000000000..fe89370e0
--- /dev/null
+++ b/changelogs/unreleased/sh-remote-branch-load-first.yml
@@ -0,0 +1,5 @@
+---
+title: Ensure local branches are current when syncing remote mirrors
+merge_request: 2606
+author:
+type: fixed
diff --git a/ruby/lib/gitlab/git/remote_mirror.rb b/ruby/lib/gitlab/git/remote_mirror.rb
index 0d4a6b34b..e95ac4df4 100644
--- a/ruby/lib/gitlab/git/remote_mirror.rb
+++ b/ruby/lib/gitlab/git/remote_mirror.rb
@@ -20,7 +20,10 @@ module Gitlab
def update
ssh_auth.setup do |env|
- updated_branches = changed_refs(local_branches, remote_branches(env: env))
+ # Retrieve the remote branches first since they may take a while to load,
+ # and the local branches may have changed during this time.
+ remote_branch_list = remote_branches(env: env)
+ updated_branches = changed_refs(local_branches, remote_branch_list)
push_refs(default_branch_first(updated_branches.keys), env: env)
delete_refs(local_branches, remote_branches(env: env), env: env)