summaryrefslogtreecommitdiff
path: root/app/models/note.rb
diff options
context:
space:
mode:
authorDominik Sander <git@dsander.de>2015-04-03 16:46:23 +0200
committerDominik Sander <git@dsander.de>2015-04-15 18:23:57 +0200
commitd4fec49abc0fceec11f970c0699dfe71ee185290 (patch)
treece687bb7745e08199f4592640e05c0b56d33de1b /app/models/note.rb
parent5f78601c8a67028f246134d325cca99952ba78b6 (diff)
downloadgitlab-ce-d4fec49abc0fceec11f970c0699dfe71ee185290.tar.gz
Fix merge request comments on files with multiple commits
Having a merge request with a comments on a line which is then changed in a later commit prevented new comments from properly showing up in the merge request show page. * `Note#set_diff` do not use stored the diff when creating a new note in merge requests (we can not be sure the diff did not changed since the last comment on that line) * Do not rely just on `outdated?` of the first note when displaying comments of a MR in the discussion tab, but partition the active/outdated notes and display them all * In the inline changes tab just select the active notes, so an outdated note does not prevent an active one from being rendered * Just show active comments in the side-by-side changes tab
Diffstat (limited to 'app/models/note.rb')
-rw-r--r--app/models/note.rb6
1 files changed, 5 insertions, 1 deletions
diff --git a/app/models/note.rb b/app/models/note.rb
index fdab4517df3..2cf3fac2def 100644
--- a/app/models/note.rb
+++ b/app/models/note.rb
@@ -354,7 +354,7 @@ class Note < ActiveRecord::Base
def set_diff
# First lets find notes with same diff
# before iterating over all mr diffs
- diff = Note.where(noteable_id: self.noteable_id, noteable_type: self.noteable_type, line_code: self.line_code).last.try(:diff)
+ diff = diff_for_line_code unless for_merge_request?
diff ||= find_diff
self.st_diff = diff.to_hash if diff
@@ -364,6 +364,10 @@ class Note < ActiveRecord::Base
@diff ||= Gitlab::Git::Diff.new(st_diff) if st_diff.respond_to?(:map)
end
+ def diff_for_line_code
+ Note.where(noteable_id: noteable_id, noteable_type: noteable_type, line_code: line_code).last.try(:diff)
+ end
+
# Check if such line of code exists in merge request diff
# If exists - its active discussion
# If not - its outdated diff