Commit f2977c63 authored by Nick Thomas's avatar Nick Thomas

Fix bitbucket wiki import with hashed storage enabled

parent 9414bb00
---
title: Fix bitbucket wiki import with hashed storage enabled
merge_request: 15490
author:
type: fixed
...@@ -61,9 +61,9 @@ module Gitlab ...@@ -61,9 +61,9 @@ module Gitlab
def import_wiki def import_wiki
return if project.wiki.repository_exists? 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") 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 rescue StandardError => e
errors << { type: :wiki, errors: e.message } errors << { type: :wiki, errors: e.message }
end end
......
...@@ -54,11 +54,13 @@ describe Gitlab::BitbucketImport::Importer do ...@@ -54,11 +54,13 @@ describe Gitlab::BitbucketImport::Importer do
create( create(
:project, :project,
import_source: project_identifier, import_source: project_identifier,
import_url: "https://bitbucket.org/#{project_identifier}.git",
import_data_attributes: { credentials: data } import_data_attributes: { credentials: data }
) )
end end
let(:importer) { described_class.new(project) } let(:importer) { described_class.new(project) }
let(:gitlab_shell) { double }
let(:issues_statuses_sample_data) do let(:issues_statuses_sample_data) do
{ {
...@@ -67,6 +69,10 @@ describe Gitlab::BitbucketImport::Importer do ...@@ -67,6 +69,10 @@ describe Gitlab::BitbucketImport::Importer do
} }
end end
before do
allow(importer).to receive(:gitlab_shell) { gitlab_shell }
end
context 'issues statuses' do context 'issues statuses' do
before do before do
# HACK: Bitbucket::Representation.const_get('Issue') seems to return ::Issue without this # HACK: Bitbucket::Representation.const_get('Issue') seems to return ::Issue without this
...@@ -110,15 +116,36 @@ describe Gitlab::BitbucketImport::Importer do ...@@ -110,15 +116,36 @@ describe Gitlab::BitbucketImport::Importer do
end end
it 'maps statuses to open or closed' do it 'maps statuses to open or closed' do
allow(importer).to receive(:import_wiki)
importer.execute importer.execute
expect(project.issues.where(state: "closed").size).to eq(5) expect(project.issues.where(state: "closed").size).to eq(5)
expect(project.issues.where(state: "opened").size).to eq(2) expect(project.issues.where(state: "opened").size).to eq(2)
end end
it 'calls import_wiki' do describe 'wiki import' do
expect(importer).to receive(:import_wiki) it 'is skipped when the wiki exists' do
importer.execute 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 end
end end
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