summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorValery Sizov <valery@gitlab.com>2016-12-19 20:44:57 +0200
committerValery Sizov <valery@gitlab.com>2016-12-19 20:48:08 +0200
commit5b0ebbe5b4c18c136aad2a53898c1a6441d39a9d (patch)
treea984bf0c2ff5fa499ae66a01e266c1c04bec4799 /lib
parent2c49c1af660a8e69446be442df81f9beaf0cf168 (diff)
downloadgitlab-ce-5b0ebbe5b4c18c136aad2a53898c1a6441d39a9d.tar.gz
Add Wiki import to BB importer
Diffstat (limited to 'lib')
-rw-r--r--lib/bitbucket/representation/repo.rb4
-rw-r--r--lib/gitlab/bitbucket_import/importer.rb13
-rw-r--r--lib/gitlab/bitbucket_import/project_creator.rb9
3 files changed, 25 insertions, 1 deletions
diff --git a/lib/bitbucket/representation/repo.rb b/lib/bitbucket/representation/repo.rb
index 8969ecd1c19..423eff8f2a5 100644
--- a/lib/bitbucket/representation/repo.rb
+++ b/lib/bitbucket/representation/repo.rb
@@ -51,6 +51,10 @@ module Bitbucket
raw['scm'] == 'git'
end
+ def has_wiki?
+ raw['has_wiki']
+ end
+
def visibility_level
if raw['is_private']
Gitlab::VisibilityLevel::PRIVATE
diff --git a/lib/gitlab/bitbucket_import/importer.rb b/lib/gitlab/bitbucket_import/importer.rb
index 7d2f92d577a..44323b47dca 100644
--- a/lib/gitlab/bitbucket_import/importer.rb
+++ b/lib/gitlab/bitbucket_import/importer.rb
@@ -1,6 +1,8 @@
module Gitlab
module BitbucketImport
class Importer
+ include Gitlab::ShellAdapter
+
LABELS = [{ title: 'bug', color: '#FF0000' },
{ title: 'enhancement', color: '#428BCA' },
{ title: 'proposal', color: '#69D100' },
@@ -18,6 +20,7 @@ module Gitlab
end
def execute
+ import_wiki
import_issues
import_pull_requests
handle_errors
@@ -55,6 +58,16 @@ module Gitlab
@repo ||= client.repo(project.import_source)
end
+ def import_wiki
+ return if project.wiki.repository_exists?
+
+ path_with_namespace = "#{project.path_with_namespace}.wiki"
+ import_url = project.import_url.sub(/\.git\z/, ".git/wiki")
+ gitlab_shell.import_repository(project.repository_storage_path, path_with_namespace, import_url)
+ rescue StandardError => e
+ errors << { type: :wiki, errors: e.message }
+ end
+
def import_issues
return unless repo.issues_enabled?
diff --git a/lib/gitlab/bitbucket_import/project_creator.rb b/lib/gitlab/bitbucket_import/project_creator.rb
index eb03882ab26..d94f70fd1fb 100644
--- a/lib/gitlab/bitbucket_import/project_creator.rb
+++ b/lib/gitlab/bitbucket_import/project_creator.rb
@@ -22,9 +22,16 @@ module Gitlab
import_type: 'bitbucket',
import_source: repo.full_name,
import_url: repo.clone_url(session_data[:token]),
- import_data: { credentials: session_data }
+ import_data: { credentials: session_data },
+ skip_wiki: skip_wiki
).execute
end
+
+ private
+
+ def skip_wiki
+ repo.has_wiki?
+ end
end
end
end