BigW Consortium Gitlab

Move Gitlab::BitbucketImport::KeyDeleter to it's own importer

parent 6dd88e09
......@@ -49,10 +49,6 @@ module Projects
unless importer.execute
raise Error, 'The remote data could not be imported.'
end
if project.import_type == 'bitbucket'
Gitlab::BitbucketImport::KeyDeleter.new(project).execute
end
end
def has_importer?
......
......@@ -13,12 +13,34 @@ module Gitlab
end
def execute
project_identifier = project.import_source
import_issues if has_issues?
return true unless client.project(project_identifier)["has_issues"]
true
ensure
Gitlab::BitbucketImport::KeyDeleter.new(project).execute
end
private
def gl_user_id(project, bitbucket_id)
if bitbucket_id
user = User.joins(:identities).find_by("identities.extern_uid = ? AND identities.provider = 'bitbucket'", bitbucket_id.to_s)
(user && user.id) || project.creator_id
else
project.creator_id
end
end
def identifier
project.import_source
end
#Issues && Comments
issues = client.issues(project_identifier)
def has_issues?
client.project(identifier)["has_issues"]
end
def import_issues
issues = client.issues(identifier)
issues.each do |issue|
body = ''
......@@ -33,7 +55,7 @@ module Gitlab
body = @formatter.author_line(author)
body += issue["content"]
comments = client.issue_comments(project_identifier, issue["local_id"])
comments = client.issue_comments(identifier, issue["local_id"])
if comments.any?
body += @formatter.comments_header
......@@ -56,19 +78,8 @@ module Gitlab
author_id: gl_user_id(project, reporter)
)
end
true
end
private
def gl_user_id(project, bitbucket_id)
if bitbucket_id
user = User.joins(:identities).find_by("identities.extern_uid = ? AND identities.provider = 'bitbucket'", bitbucket_id.to_s)
(user && user.id) || project.creator_id
else
project.creator_id
end
rescue ActiveRecord::RecordInvalid => e
raise Projects::ImportService::Error, e.message
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