Commit fff7ebeb authored by Max Woolf's avatar Max Woolf

Merge branch 'pks-drop-set-config' into 'master'

Always use `SetFullPath` RPC

See merge request gitlab-org/gitlab!68745
parents e906f85f 76dd0f25
---
name: set_full_path
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/66929
rollout_issue_url: https://gitlab.com/gitlab-org/gitlab/-/issues/337002
milestone: '14.2'
type: development
group: group::gitaly
default_enabled: false
......@@ -898,17 +898,7 @@ module Gitlab
# This guard avoids Gitaly log/error spam
raise NoRepository, 'repository does not exist' unless exists?
if Feature.enabled?(:set_full_path)
gitaly_repository_client.set_full_path(full_path)
else
set_config('gitlab.fullpath' => full_path)
end
end
def set_config(entries)
wrapped_gitaly_errors do
gitaly_repository_client.set_config(entries)
end
gitaly_repository_client.set_full_path(full_path)
end
def disconnect_alternates
......
......@@ -264,25 +264,6 @@ module Gitlab
nil
end
def set_config(entries)
return if entries.empty?
request = Gitaly::SetConfigRequest.new(repository: @gitaly_repo)
entries.each do |key, value|
request.entries << build_set_config_entry(key, value)
end
GitalyClient.call(
@storage,
:repository_service,
:set_config,
request,
timeout: GitalyClient.fast_timeout
)
nil
end
def license_short_name
request = Gitaly::FindLicenseRequest.new(repository: @gitaly_repo)
......
......@@ -1710,83 +1710,42 @@ RSpec.describe Gitlab::Git::Repository, :seed_helper do
end
describe '#set_full_path' do
shared_examples '#set_full_path' do
before do
repository_rugged.config["gitlab.fullpath"] = repository_path
end
context 'is given a path' do
it 'writes it to disk' do
repository.set_full_path(full_path: "not-the/real-path.git")
config = File.read(File.join(repository_path, "config"))
expect(config).to include("[gitlab]")
expect(config).to include("fullpath = not-the/real-path.git")
end
end
context 'it is given an empty path' do
it 'does not write it to disk' do
repository.set_full_path(full_path: "")
config = File.read(File.join(repository_path, "config"))
expect(config).to include("[gitlab]")
expect(config).to include("fullpath = #{repository_path}")
end
end
before do
repository_rugged.config["gitlab.fullpath"] = repository_path
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', '', 'group/project')
context 'is given a path' do
it 'writes it to disk' do
repository.set_full_path(full_path: "not-the/real-path.git")
expect(repository.gitaly_repository_client).not_to receive(:set_full_path)
config = File.read(File.join(repository_path, "config"))
expect do
repository.set_full_path(full_path: 'foo/bar.git')
end.to raise_error(Gitlab::Git::Repository::NoRepository)
end
expect(config).to include("[gitlab]")
expect(config).to include("fullpath = not-the/real-path.git")
end
end
context 'with :set_full_path enabled' do
before do
stub_feature_flags(set_full_path: true)
end
context 'it is given an empty path' do
it 'does not write it to disk' do
repository.set_full_path(full_path: "")
it_behaves_like '#set_full_path'
end
config = File.read(File.join(repository_path, "config"))
context 'with :set_full_path disabled' do
before do
stub_feature_flags(set_full_path: false)
expect(config).to include("[gitlab]")
expect(config).to include("fullpath = #{repository_path}")
end
it_behaves_like '#set_full_path'
end
end
describe '#set_config' do
let(:repository) { mutable_repository }
let(:entries) do
{
'test.foo1' => 'bla bla',
'test.foo2' => 1234,
'test.foo3' => true
}
end
it 'can set config settings' do
expect(repository.set_config(entries)).to be_nil
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', '', 'group/project')
expect(repository_rugged.config['test.foo1']).to eq('bla bla')
expect(repository_rugged.config['test.foo2']).to eq('1234')
expect(repository_rugged.config['test.foo3']).to eq('true')
end
expect(repository.gitaly_repository_client).not_to receive(:set_full_path)
after do
entries.keys.each { |k| repository_rugged.config.delete(k) }
expect do
repository.set_full_path(full_path: 'foo/bar.git')
end.to raise_error(Gitlab::Git::Repository::NoRepository)
end
end
end
......
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