Commit fedc82f4 authored by Stan Hu's avatar Stan Hu

Merge branch 'sh-fix-issue-9084' into 'master'

Geo: Always update the default branch on the secondary

Closes #9084

See merge request gitlab-org/gitlab-ee!9064
parents 8e27dcc8 043f8273
...@@ -476,7 +476,7 @@ module EE ...@@ -476,7 +476,7 @@ module EE
# Update the default branch querying the remote to determine its HEAD # Update the default branch querying the remote to determine its HEAD
def update_root_ref(remote_name) def update_root_ref(remote_name)
root_ref = repository.find_remote_root_ref(remote_name) root_ref = repository.find_remote_root_ref(remote_name)
change_head(root_ref) if root_ref.present? && root_ref != default_branch change_head(root_ref) if root_ref.present?
end end
def feature_flags_client_token def feature_flags_client_token
......
---
title: 'Geo: Always update the default branch on the secondary'
merge_request: 9064
author:
type: fixed
...@@ -1520,11 +1520,16 @@ describe Project do ...@@ -1520,11 +1520,16 @@ describe Project do
.to('feature') .to('feature')
end end
it 'does not update the default branch when HEAD does not change' do it 'always updates the default branch even when HEAD does not change' do
stub_find_remote_root_ref(project, ref: 'master') stub_find_remote_root_ref(project, ref: 'master')
expect { project.update_root_ref('origin') } expect(project).to receive(:change_head).with('master').and_call_original
.not_to change { project.default_branch }
project.update_root_ref('origin')
# For good measure, expunge the root ref cache and reload.
project.repository.expire_all_method_caches
expect(project.reload.default_branch).to eq('master')
end end
it 'does not update the default branch when HEAD does not exist' do it 'does not update the default branch when HEAD does not exist' do
......
...@@ -253,8 +253,8 @@ describe Geo::RepositorySyncService do ...@@ -253,8 +253,8 @@ describe Geo::RepositorySyncService do
.and_return(project.default_branch) .and_return(project.default_branch)
end end
it 'does not sync gitattributes to info/attributes' do it 'syncs gitattributes to info/attributes' do
expect(repository).not_to receive(:copy_gitattributes) expect(repository).to receive(:copy_gitattributes)
subject.execute subject.execute
end end
...@@ -265,7 +265,7 @@ describe Geo::RepositorySyncService do ...@@ -265,7 +265,7 @@ describe Geo::RepositorySyncService do
.twice .twice
.and_call_original .and_call_original
expect(project).not_to receive(:change_head) expect(project).to receive(:change_head).with('master').once
subject.execute subject.execute
end end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment