Commit 3201988b authored by Sean McGivern's avatar Sean McGivern

Merge branch 'write-config-not-found' into 'master'

Prevent Gitaly WriteConfig log noise

Closes gitaly#1221

See merge request gitlab-org/gitlab-ce!19375
parents 40dc82f8 3a4ecfd0
......@@ -1397,6 +1397,11 @@ module Gitlab
def write_config(full_path:)
return unless full_path.present?
# This guard avoids Gitaly log/error spam
unless exists?
raise NoRepository, 'repository does not exist'
end
gitaly_migrate(:write_config) do |is_enabled|
if is_enabled
gitaly_repository_client.write_config(full_path: full_path)
......
......@@ -2002,6 +2002,18 @@ describe Gitlab::Git::Repository, seed_helper: true do
expect(config).to include("fullpath = #{repository_path}")
end
end
context 'repository does not exist' do
it 'raises NoRepository and does not call Gitaly WriteConfig' do
repository = Gitlab::Git::Repository.new('default', 'does/not/exist.git', '')
expect(repository.gitaly_repository_client).not_to receive(:write_config)
expect do
repository.write_config(full_path: 'foo/bar.git')
end.to raise_error(Gitlab::Git::Repository::NoRepository)
end
end
end
context "when gitaly_write_config is enabled" 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