diff options
author | Ahmad Sherif <me@ahmadsherif.com> | 2016-10-27 15:08:37 +0200 |
---|---|---|
committer | Ahmad Sherif <me@ahmadsherif.com> | 2016-10-27 15:42:29 +0200 |
commit | ce38ae8ca15714e710c5198d201336f3651ad788 (patch) | |
tree | 38d5d31f92de1b86c8f15faeab7bdf4b76029c16 /lib | |
parent | 4259334fb64ef49580e58d434bc63d3c4738a77c (diff) | |
download | gitlab-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.rb | 13 |
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 |