Commit 3a4ecfd0 authored by Jacob Vosmaer (GitLab)'s avatar Jacob Vosmaer (GitLab) Committed by Sean McGivern

Prevent Gitaly WriteConfig log noise

parent 40dc82f8
...@@ -1397,6 +1397,11 @@ module Gitlab ...@@ -1397,6 +1397,11 @@ module Gitlab
def write_config(full_path:) def write_config(full_path:)
return unless full_path.present? 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| gitaly_migrate(:write_config) do |is_enabled|
if is_enabled if is_enabled
gitaly_repository_client.write_config(full_path: full_path) gitaly_repository_client.write_config(full_path: full_path)
......
...@@ -2002,6 +2002,18 @@ describe Gitlab::Git::Repository, seed_helper: true do ...@@ -2002,6 +2002,18 @@ describe Gitlab::Git::Repository, seed_helper: true do
expect(config).to include("fullpath = #{repository_path}") expect(config).to include("fullpath = #{repository_path}")
end end
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 end
context "when gitaly_write_config is enabled" do 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