Commit ae59c77f authored by Nick Thomas's avatar Nick Thomas

Merge branch '4101-sync-gitattributes-geo' into 'master'

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

Closes #4101

See merge request gitlab-org/gitlab-ee!4159
parents 858e6698 5514099c
---
title: 'Geo: sync .gitattributes to info/attributes in secondary nodes'
merge_request: 4159
author:
type: changed
......@@ -22,6 +22,8 @@ module Geo
fetch_geo_mirror(project.repository)
end
update_gitattributes
update_registry!(finished_at: DateTime.now, attrs: { last_repository_sync_failure: nil })
log_info('Finished repository sync',
update_delay_s: update_delay_in_seconds,
......@@ -52,6 +54,13 @@ module Geo
project.repository
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
registry.public_send("#{type}_retry_count") || -1 # rubocop:disable GitlabSecurity/PublicSend
end
......
......@@ -145,6 +145,16 @@ describe Geo::RepositorySyncService do
expect(registry.reload.repository_retry_count).to be_nil
expect(registry.repository_retry_at).to be_nil
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
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