Skip to content
Snippets Groups Projects
Commit 7462a8f9 authored by Douglas Barbosa Alexandre's avatar Douglas Barbosa Alexandre
Browse files

Apply GitHub labels to Issue/Merge Request that were imported

parent 05a4f444
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -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)
Loading
Loading
@@ -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
Loading
Loading
@@ -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)
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment