summaryrefslogtreecommitdiff
path: root/lib/gitlab/bitbucket_import
diff options
context:
space:
mode:
authorDouglas Barbosa Alexandre <dbalexandre@gmail.com>2016-08-22 16:15:39 -0300
committerStan Hu <stanhu@gmail.com>2016-11-21 16:47:27 -0800
commit704115c726999d6f0467bbf70087db3ae690d3ab (patch)
tree568936c12663b4b19a3391e72c2e1dacbc74d269 /lib/gitlab/bitbucket_import
parent64722a15e39436820a0636804179cf8c8957197e (diff)
downloadgitlab-ce-704115c726999d6f0467bbf70087db3ae690d3ab.tar.gz
Import opened pull request from Bitbucket
Diffstat (limited to 'lib/gitlab/bitbucket_import')
-rw-r--r--lib/gitlab/bitbucket_import/importer.rb31
1 files changed, 31 insertions, 0 deletions
diff --git a/lib/gitlab/bitbucket_import/importer.rb b/lib/gitlab/bitbucket_import/importer.rb
index 67e906431f0..0060e350249 100644
--- a/lib/gitlab/bitbucket_import/importer.rb
+++ b/lib/gitlab/bitbucket_import/importer.rb
@@ -11,6 +11,7 @@ module Gitlab
def execute
import_issues
+ import_pull_requests
true
end
@@ -72,6 +73,36 @@ module Gitlab
rescue ActiveRecord::RecordInvalid
nil
end
+
+ def import_pull_requests
+ pull_requests = client.pull_requests(repo)
+
+ pull_requests.each do |pull_request|
+ begin
+ description = @formatter.author_line(pull_request.author)
+ description += pull_request.description
+
+ project.merge_requests.create(
+ iid: pull_request.iid,
+ title: pull_request.title,
+ description: description,
+ source_project: project,
+ source_branch: pull_request.source_branch_name,
+ source_branch_sha: pull_request.source_branch_sha,
+ target_project: project,
+ target_branch: pull_request.target_branch_name,
+ target_branch_sha: pull_request.target_branch_sha,
+ state: pull_request.state,
+ author_id: gl_user_id(project, pull_request.author),
+ assignee_id: nil,
+ created_at: pull_request.created_at,
+ updated_at: pull_request.updated_at
+ )
+ rescue ActiveRecord::RecordInvalid
+ nil
+ end
+ end
+ end
end
end
end