Commit 5514099c authored by Gabriel Mazetto's avatar Gabriel Mazetto Committed by Nick Thomas

Geo: sync .gitattributes to info/attributes in secondary nodes

parent 858e6698
---
title: 'Geo: sync .gitattributes to info/attributes in secondary nodes'
merge_request: 4159
author:
type: changed
...@@ -22,6 +22,8 @@ module Geo ...@@ -22,6 +22,8 @@ module Geo
fetch_geo_mirror(project.repository) fetch_geo_mirror(project.repository)
end end
update_gitattributes
update_registry!(finished_at: DateTime.now, attrs: { last_repository_sync_failure: nil }) update_registry!(finished_at: DateTime.now, attrs: { last_repository_sync_failure: nil })
log_info('Finished repository sync', log_info('Finished repository sync',
update_delay_s: update_delay_in_seconds, update_delay_s: update_delay_in_seconds,
...@@ -52,6 +54,13 @@ module Geo ...@@ -52,6 +54,13 @@ module Geo
project.repository project.repository
end end
# Update info/attributes file using the contents of .gitattributes file from the default branch
def update_gitattributes
return if project.default_branch.nil?
repository.copy_gitattributes(project.default_branch)
end
def retry_count def retry_count
registry.public_send("#{type}_retry_count") || -1 # rubocop:disable GitlabSecurity/PublicSend registry.public_send("#{type}_retry_count") || -1 # rubocop:disable GitlabSecurity/PublicSend
end end
......
...@@ -145,6 +145,16 @@ describe Geo::RepositorySyncService do ...@@ -145,6 +145,16 @@ describe Geo::RepositorySyncService do
expect(registry.reload.repository_retry_count).to be_nil expect(registry.reload.repository_retry_count).to be_nil
expect(registry.repository_retry_at).to be_nil expect(registry.repository_retry_at).to be_nil
end end
context 'with non empty repositories' do
let(:project) { create(:project, :repository) }
it 'syncs gitattributes to info/attributes' do
expect(repository).to receive(:copy_gitattributes)
subject.execute
end
end
end end
context 'when repository sync fail' do context 'when repository sync fail' do
......
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