summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDouglas Barbosa Alexandre <dbalexandre@gmail.com>2017-04-25 17:05:40 -0300
committerDouglas Barbosa Alexandre <dbalexandre@gmail.com>2017-04-25 17:05:40 -0300
commit44954c507ed99db892e9e4e40779bc6fc6f0a56f (patch)
tree21edc94dc1e887076cb5737f414887f968d1bb41
parent39ab842bc2ff1395ed1bf6768ff2a409a33bf3d3 (diff)
downloadgitlab-ce-44954c507ed99db892e9e4e40779bc6fc6f0a56f.tar.gz
Fix import of notes on Pull Request diff
-rw-r--r--lib/github/import.rb15
-rw-r--r--lib/github/representation/comment.rb4
-rw-r--r--lib/github/response.rb2
3 files changed, 12 insertions, 9 deletions
diff --git a/lib/github/import.rb b/lib/github/import.rb
index a0afd12f45f..96b69d78c55 100644
--- a/lib/github/import.rb
+++ b/lib/github/import.rb
@@ -30,6 +30,14 @@ module Github
self.reset_callbacks :validate
end
+ class LegacyDiffNote < ::LegacyDiffNote
+ self.table_name = 'notes'
+
+ self.reset_callbacks :commit
+ self.reset_callbacks :update
+ self.reset_callbacks :validate
+ end
+
attr_reader :project, :repository, :repo, :options, :errors, :cached
def initialize(project, options)
@@ -177,7 +185,7 @@ module Github
# Fetch review comments
review_comments_url = "/repos/#{repo}/pulls/#{pull_request.iid}/comments"
- fetch_comments(merge_request, :review_comment, review_comments_url)
+ fetch_comments(merge_request, :review_comment, review_comments_url, LegacyDiffNote)
# Fetch comments
comments_url = "/repos/#{repo}/issues/#{pull_request.iid}/comments"
@@ -245,7 +253,7 @@ module Github
end
end
- def fetch_comments(noteable, type, url)
+ def fetch_comments(noteable, type, url, klass = Note)
while url
comments = Github::Client.new(options).get(url)
@@ -255,14 +263,13 @@ module Github
representation = Github::Representation::Comment.new(raw, options)
author_id = user_id(representation.author, project.creator_id)
- note = Note.new
+ note = klass.new
note.project_id = project.id
note.noteable = noteable
note.note = format_description(representation.note, representation.author)
note.commit_id = representation.commit_id
note.line_code = representation.line_code
note.author_id = author_id
- note.type = representation.type
note.created_at = representation.created_at
note.updated_at = representation.updated_at
note.save!(validate: false)
diff --git a/lib/github/representation/comment.rb b/lib/github/representation/comment.rb
index 22cb98b0eff..1b5be91461b 100644
--- a/lib/github/representation/comment.rb
+++ b/lib/github/representation/comment.rb
@@ -20,10 +20,6 @@ module Github
generate_line_code(parsed_lines.to_a.last)
end
- def type
- 'LegacyDiffNote' if on_diff?
- end
-
private
def generate_line_code(line)
diff --git a/lib/github/response.rb b/lib/github/response.rb
index 2fd07dd822e..761c524b553 100644
--- a/lib/github/response.rb
+++ b/lib/github/response.rb
@@ -9,7 +9,7 @@ module Github
end
def body
- @body ||= Oj.load(raw.body, class_cache: false, mode: :compat)
+ Oj.load(raw.body, class_cache: false, mode: :compat)
end
def rels