summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorAhmad Sherif <me@ahmadsherif.com>2016-10-27 15:08:37 +0200
committerAhmad Sherif <me@ahmadsherif.com>2016-10-27 15:42:29 +0200
commitce38ae8ca15714e710c5198d201336f3651ad788 (patch)
tree38d5d31f92de1b86c8f15faeab7bdf4b76029c16 /lib
parent4259334fb64ef49580e58d434bc63d3c4738a77c (diff)
downloadgitlab-ce-ce38ae8ca15714e710c5198d201336f3651ad788.tar.gz
Fix importing MR comments from GitHubfix/gh-import-bugs
Diffstat (limited to 'lib')
-rw-r--r--lib/gitlab/github_import/importer.rb13
1 files changed, 7 insertions, 6 deletions
diff --git a/lib/gitlab/github_import/importer.rb b/lib/gitlab/github_import/importer.rb
index 4ac932dc213..27946dff608 100644
--- a/lib/gitlab/github_import/importer.rb
+++ b/lib/gitlab/github_import/importer.rb
@@ -150,21 +150,22 @@ module Gitlab
def import_comments
client.issues_comments(repo, per_page: 100) do |comments|
- create_comments(comments, :issue)
+ create_comments(comments)
end
client.pull_requests_comments(repo, per_page: 100) do |comments|
- create_comments(comments, :pull_request)
+ create_comments(comments)
end
end
- def create_comments(comments, issuable_type)
+ def create_comments(comments)
ActiveRecord::Base.no_touching do
comments.each do |raw|
begin
- comment = CommentFormatter.new(project, raw)
- issuable_class = issuable_type == :issue ? Issue : MergeRequest
- iid = raw.send("#{issuable_type}_url").split('/').last # GH doesn't return parent ID directly
+ comment = CommentFormatter.new(project, raw)
+ # GH does not return info about comment's parent, so we guess it by checking its URL!
+ *_, parent, iid = URI(raw.html_url).path.split('/')
+ issuable_class = parent == 'issues' ? Issue : MergeRequest
issuable = issuable_class.find_by_iid(iid)
next unless issuable