Commit 8c2e2e1c authored by Jacob Vosmaer (GitLab)'s avatar Jacob Vosmaer (GitLab) Committed by Nick Thomas

Use gitaly to set/unset git config

parent 46cae736
......@@ -11,17 +11,12 @@ module EE
end
# Transiently sets a configuration variable
# Gitaly migration: https://gitlab.com/gitlab-org/gitaly/issues/1241
def with_config(values = {})
::Gitlab::GitalyClient::StorageSettings.allow_disk_access do
values.each { |k, v| rugged.config[k] = v }
end
raw_repository.set_config(values)
yield
ensure
::Gitlab::GitalyClient::StorageSettings.allow_disk_access do
values.keys.each { |key| rugged.config.delete(key) }
end
raw_repository.delete_config(*values.keys)
end
# Runs code after a repository has been synced.
......
......@@ -34,6 +34,33 @@ describe Repository do
end
end
describe '#with_config' do
let(:rugged) do
Gitlab::GitalyClient::StorageSettings.allow_disk_access do
repository.rugged
end
end
let(:entries) { { 'test.foo1' => 'hello', 'test.foo2' => 'world' } }
it 'sets config only during the block' do
keys_should_not_be_set
repository.with_config(entries) do
entries.each do |key, value|
expect(rugged.config[key]).to eq(value)
end
end
keys_should_not_be_set
end
def keys_should_not_be_set
entries.each do |key, value|
expect(rugged.config[key]).to be_blank
end
end
end
describe "Elastic search", :elastic do
before do
stub_ee_application_setting(elasticsearch_search: true, elasticsearch_indexing: true)
......
......@@ -283,7 +283,11 @@ describe Geo::RepositorySyncService do
subject.execute
expect(File.directory?(project.repository.path)).to be true
repo_path = Gitlab::GitalyClient::StorageSettings.allow_disk_access do
project.repository.path
end
expect(File.directory?(repo_path)).to be true
end
it 'tries to redownload repo when force_redownload flag is set' 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