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,6 +215,14 @@ describe Geo::RepositorySyncService do
context 'with non empty repositories' do
let(:project) { create(:project, :repository) }
context 'when when HEAD change' do
before do
allow(project.repository)
.to receive(:find_remote_root_ref)
.with('geo')
.and_return('feature')
end
it 'syncs gitattributes to info/attributes' do
expect(repository).to receive(:copy_gitattributes)
......@@ -222,15 +230,32 @@ describe Geo::RepositorySyncService do
end
it 'updates the default branch' do
expect(project).to receive(:change_head).with('feature').once
subject.execute
end
end
context 'when HEAD does not change' do
before do
allow(project.repository)
.to receive(:find_remote_root_ref)
.with('geo')
.and_return('development')
.and_return(project.default_branch)
end
expect(project).to receive(:change_head).with('development').once
it 'does not sync gitattributes to info/attributes' do
expect(repository).not_to receive(:copy_gitattributes)
subject.execute
end
it 'does not update the default branch' do
expect(project).not_to receive(:change_head)
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