Doesn't update default branch when HEAD doesn't change

parent 62c2e8bc
......@@ -48,7 +48,7 @@ module Geo
# Update the default branch querying the remote to determine its HEAD
def update_root_ref
root_ref = repository.find_remote_root_ref(GEO_REMOTE_NAME)
project.change_head(root_ref) if root_ref.present?
project.change_head(root_ref) if root_ref.present? && root_ref != project.default_branch
end
def schedule_repack
......
......@@ -215,21 +215,46 @@ describe Geo::RepositorySyncService do
context 'with non empty repositories' do
let(:project) { create(:project, :repository) }
it 'syncs gitattributes to info/attributes' do
expect(repository).to receive(:copy_gitattributes)
context 'when when HEAD change' do
before do
allow(project.repository)
.to receive(:find_remote_root_ref)
.with('geo')
.and_return('feature')
end
subject.execute
it 'syncs gitattributes to info/attributes' do
expect(repository).to receive(:copy_gitattributes)
subject.execute
end
it 'updates the default branch' do
expect(project).to receive(:change_head).with('feature').once
subject.execute
end
end
it 'updates the default branch' do
allow(project.repository)
.to receive(:find_remote_root_ref)
.with('geo')
.and_return('development')
context 'when HEAD does not change' do
before do
allow(project.repository)
.to receive(:find_remote_root_ref)
.with('geo')
.and_return(project.default_branch)
end
it 'does not sync gitattributes to info/attributes' do
expect(repository).not_to receive(:copy_gitattributes)
subject.execute
end
expect(project).to receive(:change_head).with('development').once
it 'does not update the default branch' do
expect(project).not_to receive(:change_head)
subject.execute
subject.execute
end
end
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