Merge branch 'zj-create-from-bundle-mandatory' into 'master'
Moves CreateFromBundle RPC to mandatory Closes gitaly#944 See merge request gitlab-org/gitlab-ce!20144
This commit is contained in:
commit
77fe416681
4 changed files with 25 additions and 44 deletions
|
@ -21,7 +21,7 @@ class Repository
|
||||||
attr_accessor :full_path, :disk_path, :project, :is_wiki
|
attr_accessor :full_path, :disk_path, :project, :is_wiki
|
||||||
|
|
||||||
delegate :ref_name_for_sha, to: :raw_repository
|
delegate :ref_name_for_sha, to: :raw_repository
|
||||||
delegate :bundle_to_disk, :create_from_bundle, to: :raw_repository
|
delegate :bundle_to_disk, to: :raw_repository
|
||||||
|
|
||||||
CreateTreeError = Class.new(StandardError)
|
CreateTreeError = Class.new(StandardError)
|
||||||
|
|
||||||
|
|
|
@ -1122,16 +1122,7 @@ module Gitlab
|
||||||
end
|
end
|
||||||
|
|
||||||
def create_from_bundle(bundle_path)
|
def create_from_bundle(bundle_path)
|
||||||
gitaly_migrate(:create_repo_from_bundle) do |is_enabled|
|
gitaly_repository_client.create_from_bundle(bundle_path)
|
||||||
if is_enabled
|
|
||||||
gitaly_repository_client.create_from_bundle(bundle_path)
|
|
||||||
else
|
|
||||||
run_git!(%W(clone --bare -- #{bundle_path} #{path}), chdir: nil)
|
|
||||||
self.class.create_hooks(path, File.expand_path(Gitlab.config.gitlab_shell.hooks_path))
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
true
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def create_from_snapshot(url, auth)
|
def create_from_snapshot(url, auth)
|
||||||
|
|
|
@ -2150,43 +2150,33 @@ describe Gitlab::Git::Repository, seed_helper: true do
|
||||||
end
|
end
|
||||||
|
|
||||||
describe '#create_from_bundle' do
|
describe '#create_from_bundle' do
|
||||||
shared_examples 'creating repo from bundle' do
|
let(:bundle_path) { File.join(Dir.tmpdir, "repo-#{SecureRandom.hex}.bundle") }
|
||||||
let(:bundle_path) { File.join(Dir.tmpdir, "repo-#{SecureRandom.hex}.bundle") }
|
let(:project) { create(:project) }
|
||||||
let(:project) { create(:project) }
|
let(:imported_repo) { project.repository.raw }
|
||||||
let(:imported_repo) { project.repository.raw }
|
|
||||||
|
|
||||||
before do
|
before do
|
||||||
expect(repository.bundle_to_disk(bundle_path)).to be true
|
expect(repository.bundle_to_disk(bundle_path)).to be_truthy
|
||||||
end
|
|
||||||
|
|
||||||
after do
|
|
||||||
FileUtils.rm_rf(bundle_path)
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'creates a repo from a bundle file' do
|
|
||||||
expect(imported_repo).not_to exist
|
|
||||||
|
|
||||||
result = imported_repo.create_from_bundle(bundle_path)
|
|
||||||
|
|
||||||
expect(result).to be true
|
|
||||||
expect(imported_repo).to exist
|
|
||||||
expect { imported_repo.fsck }.not_to raise_exception
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'creates a symlink to the global hooks dir' do
|
|
||||||
imported_repo.create_from_bundle(bundle_path)
|
|
||||||
hooks_path = Gitlab::GitalyClient::StorageSettings.allow_disk_access { File.join(imported_repo.path, 'hooks') }
|
|
||||||
|
|
||||||
expect(File.readlink(hooks_path)).to eq(Gitlab.config.gitlab_shell.hooks_path)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'when Gitaly create_repo_from_bundle feature is enabled' do
|
after do
|
||||||
it_behaves_like 'creating repo from bundle'
|
FileUtils.rm_rf(bundle_path)
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'when Gitaly create_repo_from_bundle feature is disabled', :disable_gitaly do
|
it 'creates a repo from a bundle file' do
|
||||||
it_behaves_like 'creating repo from bundle'
|
expect(imported_repo).not_to exist
|
||||||
|
|
||||||
|
result = imported_repo.create_from_bundle(bundle_path)
|
||||||
|
|
||||||
|
expect(result).to be_truthy
|
||||||
|
expect(imported_repo).to exist
|
||||||
|
expect { imported_repo.fsck }.not_to raise_exception
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'creates a symlink to the global hooks dir' do
|
||||||
|
imported_repo.create_from_bundle(bundle_path)
|
||||||
|
hooks_path = Gitlab::GitalyClient::StorageSettings.allow_disk_access { File.join(imported_repo.path, 'hooks') }
|
||||||
|
|
||||||
|
expect(File.readlink(hooks_path)).to eq(Gitlab.config.gitlab_shell.hooks_path)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -30,7 +30,7 @@ describe Gitlab::ImportExport::RepoRestorer do
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'restores the repo successfully' do
|
it 'restores the repo successfully' do
|
||||||
expect(restorer.restore).to be true
|
expect(restorer.restore).to be_truthy
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'has the webhooks' do
|
it 'has the webhooks' do
|
||||||
|
|
Loading…
Reference in a new issue