Commit a1c559be authored by Grzegorz Bizon's avatar Grzegorz Bizon

Merge branch 'gitaly-set-config-2' into 'master'

Use Gitaly to set/unset git config, take 2

Closes gitaly#1241

See merge request gitlab-org/gitlab-ee!6458
parents 78e0fa3e 0d0aa5ba
...@@ -11,17 +11,12 @@ module EE ...@@ -11,17 +11,12 @@ module EE
end end
# Transiently sets a configuration variable # Transiently sets a configuration variable
# Gitaly migration: https://gitlab.com/gitlab-org/gitaly/issues/1241
def with_config(values = {}) def with_config(values = {})
::Gitlab::GitalyClient::StorageSettings.allow_disk_access do raw_repository.set_config(values)
values.each { |k, v| rugged.config[k] = v }
end
yield yield
ensure ensure
::Gitlab::GitalyClient::StorageSettings.allow_disk_access do raw_repository.delete_config(*values.keys)
values.keys.each { |key| rugged.config.delete(key) }
end
end end
# Runs code after a repository has been synced. # Runs code after a repository has been synced.
......
...@@ -34,6 +34,39 @@ describe Repository do ...@@ -34,6 +34,39 @@ describe Repository do
end end
end end
describe '#with_config' do
let(:rugged) do
Gitlab::GitalyClient::StorageSettings.allow_disk_access do
repository.rugged
end
end
let(:entries) do
{
'test.foo1' => 'hello',
'test.foo2' => 'world',
'http.http://gitlab-primary.geo/gitlab-qa-sandbox-group/qa-test-10-07-2018-07-22-41/geo-project-ac55ec2cd134afea.wiki.git.extraHeader' => 'Authorization: blabla'
}
end
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 describe "Elastic search", :elastic do
before do before do
stub_ee_application_setting(elasticsearch_search: true, elasticsearch_indexing: true) stub_ee_application_setting(elasticsearch_search: true, elasticsearch_indexing: true)
......
...@@ -286,7 +286,11 @@ describe Geo::RepositorySyncService do ...@@ -286,7 +286,11 @@ describe Geo::RepositorySyncService do
subject.execute 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 end
it 'tries to redownload repo when force_redownload flag is set' do 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