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
# Update the default branch querying the remote to determine its HEAD
def update_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
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
.to('feature')
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')
expect { project.update_root_ref('origin') }
.not_to change { project.default_branch }
expect(project).to receive(:change_head).with('master').and_call_original
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
it 'does not update the default branch when HEAD does not exist' do
......
......@@ -253,8 +253,8 @@ describe Geo::RepositorySyncService do
.and_return(project.default_branch)
end
it 'does not sync gitattributes to info/attributes' do
expect(repository).not_to receive(:copy_gitattributes)
it 'syncs gitattributes to info/attributes' do
expect(repository).to receive(:copy_gitattributes)
subject.execute
end
......@@ -265,7 +265,7 @@ describe Geo::RepositorySyncService do
.twice
.and_call_original
expect(project).not_to receive(:change_head)
expect(project).to receive(:change_head).with('master').once
subject.execute
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