Skip to content
Snippets Groups Projects
Commit c74df12f authored by James Fargher's avatar James Fargher
Browse files

Remove TestEnv.create_bare_repository

This test helper is only ever used to directly manipulate the gitaly
managed repository filesystem. Since this will stop working with
praefect, here we convert all usages to use RPCs instead.
parent 74cd79c0
No related branches found
No related tags found
1 merge request!91170Remove TestEnv.create_bare_repository
......@@ -193,8 +193,6 @@
def prepare_repository(project_path, source_project)
repo_path = File.join(base_dir, project_path)
return create_bare_repository(repo_path) unless source_project
cmd = %W(#{Gitlab.config.git.bin_path} clone --bare #{source_project} #{repo_path})
system(git_env, *cmd, chdir: SEED_STORAGE_PATH, out: '/dev/null', err: '/dev/null')
......
......@@ -59,18 +59,15 @@
let(:root_path) { TestEnv.repos_path }
let(:repo_path) { File.join(root_path, "#{hashed_path}.git") }
let(:wiki_path) { File.join(root_path, "#{hashed_path}.wiki.git") }
let(:raw_repository) { Gitlab::Git::Repository.new('default', "#{hashed_path}.git", nil, nil) }
before do
TestEnv.create_bare_repository(repo_path)
Gitlab::GitalyClient::StorageSettings.allow_disk_access do
repository = Rugged::Repository.new(repo_path)
repository.config['gitlab.fullpath'] = 'to/repo'
end
raw_repository.create_repository
raw_repository.set_full_path(full_path: 'to/repo')
end
after do
FileUtils.rm_rf(repo_path)
raw_repository.remove
end
subject { described_class.new(root_path, repo_path) }
......
......@@ -543,15 +543,15 @@ def wiki_repo(project)
end
context 'with legacy storage' do
let(:fake_repo_path) { File.join(TestEnv.repos_path, user.namespace.full_path, 'existing.git') }
let(:raw_fake_repo) { Gitlab::Git::Repository.new('default', File.join(user.namespace.full_path, 'existing.git'), nil, nil) }
before do
stub_application_setting(hashed_storage_enabled: false)
TestEnv.create_bare_repository(fake_repo_path)
raw_fake_repo.create_repository
end
after do
FileUtils.rm_rf(fake_repo_path)
raw_fake_repo.remove
end
it 'does not allow to create a project when path matches existing repository on disk' do
......@@ -578,15 +578,15 @@ def wiki_repo(project)
context 'with hashed storage' do
let(:hash) { '6b86b273ff34fce19d6b804eff5a3f5747ada4eaa22f1d49c01e52ddb7875b4b' }
let(:hashed_path) { '@hashed/6b/86/6b86b273ff34fce19d6b804eff5a3f5747ada4eaa22f1d49c01e52ddb7875b4b' }
let(:fake_repo_path) { File.join(TestEnv.repos_path, "#{hashed_path}.git") }
let(:raw_fake_repo) { Gitlab::Git::Repository.new('default', "#{hashed_path}.git", nil, nil) }
before do
allow(Digest::SHA2).to receive(:hexdigest) { hash }
TestEnv.create_bare_repository(fake_repo_path)
raw_fake_repo.create_repository
end
after do
FileUtils.rm_rf(fake_repo_path)
raw_fake_repo.remove
end
it 'does not allow to create a project when path matches existing repository on disk' do
......
......@@ -156,16 +156,16 @@
end
context 'repository in legacy storage already exists' do
let(:fake_repo_path) { File.join(TestEnv.repos_path, @to_user.namespace.full_path, "#{@from_project.path}.git") }
let(:raw_fake_repo) { Gitlab::Git::Repository.new('default', File.join(@to_user.namespace.full_path, "#{@from_project.path}.git"), nil, nil) }
let(:params) { { namespace: @to_user.namespace, using_service: true } }
before do
stub_application_setting(hashed_storage_enabled: false)
TestEnv.create_bare_repository(fake_repo_path)
raw_fake_repo.create_repository
end
after do
FileUtils.rm_rf(fake_repo_path)
raw_fake_repo.remove
end
subject { fork_project(@from_project, @to_user, params) }
......
......@@ -372,16 +372,16 @@ def current_path
end
context 'namespace which contains orphan repository with same projects path name' do
let(:fake_repo_path) { File.join(TestEnv.repos_path, group.full_path, "#{project.path}.git") }
let(:raw_fake_repo) { Gitlab::Git::Repository.new('default', File.join(group.full_path, "#{project.path}.git"), nil, nil) }
before do
group.add_owner(user)
TestEnv.create_bare_repository(fake_repo_path)
raw_fake_repo.create_repository
end
after do
FileUtils.rm_rf(fake_repo_path)
raw_fake_repo.remove
end
it 'does not allow the project transfer' do
......
......@@ -348,17 +348,17 @@
end
context 'when renaming a project' do
let(:fake_repo_path) { File.join(TestEnv.repos_path, user.namespace.full_path, 'existing.git') }
let(:raw_fake_repo) { Gitlab::Git::Repository.new('default', File.join(user.namespace.full_path, 'existing.git'), nil, nil) }
context 'with legacy storage' do
let(:project) { create(:project, :legacy_storage, :repository, creator: user, namespace: user.namespace) }
before do
TestEnv.create_bare_repository(fake_repo_path)
raw_fake_repo.create_repository
end
after do
FileUtils.rm_rf(fake_repo_path)
raw_fake_repo.remove
end
it 'does not allow renaming when new path matches existing repository on disk' do
......
......@@ -310,14 +310,6 @@ def storage_dir_exists?(storage, dir)
end
end
def create_bare_repository(path)
FileUtils.mkdir_p(path)
system(git_env, *%W(#{Gitlab.config.git.bin_path} -C #{path} init --bare),
out: '/dev/null',
err: '/dev/null')
end
def repos_path
@repos_path ||= GitalySetup.repos_path
end
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment