Commit 246ce5b5 authored by Douwe Maan's avatar Douwe Maan

Merge branch 'zj-write-config' into 'master'

Write Config is mandatory

Closes gitaly#879

See merge request gitlab-org/gitlab-ce!20146
parents 0edc12b3 08554787
...@@ -1247,16 +1247,10 @@ module Gitlab ...@@ -1247,16 +1247,10 @@ module Gitlab
return unless full_path.present? return unless full_path.present?
# This guard avoids Gitaly log/error spam # This guard avoids Gitaly log/error spam
unless exists? raise NoRepository, 'repository does not exist' unless exists?
raise NoRepository, 'repository does not exist'
end
gitaly_migrate(:write_config) do |is_enabled| wrapped_gitaly_errors do
if is_enabled gitaly_repository_client.write_config(full_path: full_path)
gitaly_repository_client.write_config(full_path: full_path)
else
rugged_write_config(full_path: full_path)
end
end end
end end
......
...@@ -1871,49 +1871,39 @@ describe Gitlab::Git::Repository, seed_helper: true do ...@@ -1871,49 +1871,39 @@ describe Gitlab::Git::Repository, seed_helper: true do
repository_rugged.config["gitlab.fullpath"] = repository_path repository_rugged.config["gitlab.fullpath"] = repository_path
end end
shared_examples 'writing repo config' do context 'is given a path' do
context 'is given a path' do it 'writes it to disk' do
it 'writes it to disk' do repository.write_config(full_path: "not-the/real-path.git")
repository.write_config(full_path: "not-the/real-path.git")
config = File.read(File.join(repository_path, "config")) config = File.read(File.join(repository_path, "config"))
expect(config).to include("[gitlab]") expect(config).to include("[gitlab]")
expect(config).to include("fullpath = not-the/real-path.git") expect(config).to include("fullpath = not-the/real-path.git")
end
end end
end
context 'it is given an empty path' do context 'it is given an empty path' do
it 'does not write it to disk' do it 'does not write it to disk' do
repository.write_config(full_path: "") repository.write_config(full_path: "")
config = File.read(File.join(repository_path, "config")) config = File.read(File.join(repository_path, "config"))
expect(config).to include("[gitlab]") expect(config).to include("[gitlab]")
expect(config).to include("fullpath = #{repository_path}") expect(config).to include("fullpath = #{repository_path}")
end
end end
end
context 'repository does not exist' do context 'repository does not exist' do
it 'raises NoRepository and does not call Gitaly WriteConfig' do it 'raises NoRepository and does not call Gitaly WriteConfig' do
repository = Gitlab::Git::Repository.new('default', 'does/not/exist.git', '') repository = Gitlab::Git::Repository.new('default', 'does/not/exist.git', '')
expect(repository.gitaly_repository_client).not_to receive(:write_config) expect(repository.gitaly_repository_client).not_to receive(:write_config)
expect do expect do
repository.write_config(full_path: 'foo/bar.git') repository.write_config(full_path: 'foo/bar.git')
end.to raise_error(Gitlab::Git::Repository::NoRepository) end.to raise_error(Gitlab::Git::Repository::NoRepository)
end
end end
end end
context "when gitaly_write_config is enabled" do
it_behaves_like "writing repo config"
end
context "when gitaly_write_config is disabled", :disable_gitaly do
it_behaves_like "writing repo config"
end
end end
describe '#merge' do describe '#merge' 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