Merge branch '40292-bitbucket-import-hashed-storage' into 'master'

Fix bitbucket wiki import with hashed storage enabled

Closes #40292

See merge request gitlab-org/gitlab-ce!15490
This commit is contained in:
Douwe Maan 2017-11-20 18:08:36 +00:00
commit c043ba67c2
3 changed files with 37 additions and 5 deletions

View file

@ -0,0 +1,5 @@
---
title: Fix bitbucket wiki import with hashed storage enabled
merge_request: 15490
author:
type: fixed

View file

@ -61,9 +61,9 @@ module Gitlab
def import_wiki
return if project.wiki.repository_exists?
path_with_namespace = "#{project.full_path}.wiki"
disk_path = project.wiki.disk_path
import_url = project.import_url.sub(/\.git\z/, ".git/wiki")
gitlab_shell.import_repository(project.repository_storage_path, path_with_namespace, import_url)
gitlab_shell.import_repository(project.repository_storage_path, disk_path, import_url)
rescue StandardError => e
errors << { type: :wiki, errors: e.message }
end

View file

@ -54,11 +54,13 @@ describe Gitlab::BitbucketImport::Importer do
create(
:project,
import_source: project_identifier,
import_url: "https://bitbucket.org/#{project_identifier}.git",
import_data_attributes: { credentials: data }
)
end
let(:importer) { described_class.new(project) }
let(:gitlab_shell) { double }
let(:issues_statuses_sample_data) do
{
@ -67,6 +69,10 @@ describe Gitlab::BitbucketImport::Importer do
}
end
before do
allow(importer).to receive(:gitlab_shell) { gitlab_shell }
end
context 'issues statuses' do
before do
# HACK: Bitbucket::Representation.const_get('Issue') seems to return ::Issue without this
@ -110,15 +116,36 @@ describe Gitlab::BitbucketImport::Importer do
end
it 'maps statuses to open or closed' do
allow(importer).to receive(:import_wiki)
importer.execute
expect(project.issues.where(state: "closed").size).to eq(5)
expect(project.issues.where(state: "opened").size).to eq(2)
end
it 'calls import_wiki' do
expect(importer).to receive(:import_wiki)
importer.execute
describe 'wiki import' do
it 'is skipped when the wiki exists' do
expect(project.wiki).to receive(:repository_exists?) { true }
expect(importer.gitlab_shell).not_to receive(:import_repository)
importer.execute
expect(importer.errors).to be_empty
end
it 'imports to the project disk_path' do
expect(project.wiki).to receive(:repository_exists?) { false }
expect(importer.gitlab_shell).to receive(:import_repository).with(
project.repository_storage_path,
project.wiki.disk_path,
project.import_url + '/wiki'
)
importer.execute
expect(importer.errors).to be_empty
end
end
end
end