summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorDouglas Barbosa Alexandre <dbalexandre@gmail.com>2016-04-18 01:02:22 -0300
committerDouglas Barbosa Alexandre <dbalexandre@gmail.com>2016-04-18 17:14:59 -0300
commit7462a8f90a719e4850a28d9c6d2f223ce1e29b69 (patch)
tree263e3b19516e01088dd69520934a90da2c28b21c /lib
parent05a4f444c368593216ab335db93ca98ce2218e94 (diff)
downloadgitlab-ce-7462a8f90a719e4850a28d9c6d2f223ce1e29b69.tar.gz
Apply GitHub labels to Issue/Merge Request that were imported
Diffstat (limited to 'lib')
-rw-r--r--lib/gitlab/github_import/importer.rb14
1 files changed, 14 insertions, 0 deletions
diff --git a/lib/gitlab/github_import/importer.rb b/lib/gitlab/github_import/importer.rb
index e406a0283b9..7f70ab63f37 100644
--- a/lib/gitlab/github_import/importer.rb
+++ b/lib/gitlab/github_import/importer.rb
@@ -43,6 +43,7 @@ module Gitlab
if gh_issue.valid?
issue = Issue.create!(gh_issue.attributes)
+ apply_labels(gh_issue.number, issue)
if gh_issue.has_comments?
import_comments(gh_issue.number, issue)
@@ -65,6 +66,7 @@ module Gitlab
merge_request = MergeRequest.new(pull_request.attributes)
if merge_request.save
+ apply_labels(pull_request.number, merge_request)
import_comments(pull_request.number, merge_request)
import_comments_on_diff(pull_request.number, merge_request)
end
@@ -76,6 +78,18 @@ module Gitlab
raise Projects::ImportService::Error, e.message
end
+ def apply_labels(number, issuable)
+ issue = client.issue(project.import_source, number)
+
+ if issue.labels.count > 0
+ label_ids = issue.labels.map do |raw|
+ Label.find_by(LabelFormatter.new(project, raw).attributes).try(:id)
+ end
+
+ issuable.update_attribute(:label_ids, label_ids)
+ end
+ end
+
def import_comments(issue_number, noteable)
comments = client.issue_comments(project.import_source, issue_number)
create_comments(comments, noteable)