summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
Diffstat (limited to 'app')
-rw-r--r--app/helpers/commits_helper.rb4
-rw-r--r--app/models/note.rb11
-rw-r--r--app/views/projects/commits/_text_file.html.haml4
-rw-r--r--app/views/projects/notes/_diff_notes_with_reply.html.haml20
4 files changed, 27 insertions, 12 deletions
diff --git a/app/helpers/commits_helper.rb b/app/helpers/commits_helper.rb
index 111e1cda19c..f808ac764d4 100644
--- a/app/helpers/commits_helper.rb
+++ b/app/helpers/commits_helper.rb
@@ -38,6 +38,8 @@ module CommitsHelper
lines_arr = ::Gitlab::InlineDiff.processing diff_arr
lines_arr.each do |line|
+ raw_line = line.dup
+
next if line.match(/^\-\-\- \/dev\/null/)
next if line.match(/^\+\+\+ \/dev\/null/)
next if line.match(/^\-\-\- a/)
@@ -58,7 +60,7 @@ module CommitsHelper
else
type = identification_type(line)
line_code = build_line_anchor(diff, line_new, line_old)
- yield(full_line, type, line_code, line_new, line_old)
+ yield(full_line, type, line_code, line_new, line_old, raw_line)
end
diff --git a/app/models/note.rb b/app/models/note.rb
index b0875a0761b..8714db2e10e 100644
--- a/app/models/note.rb
+++ b/app/models/note.rb
@@ -99,10 +99,21 @@ class Note < ActiveRecord::Base
diff.new_path if diff
end
+ def diff_old_line
+ line_code.split('_')[1].to_i
+ end
+
def diff_new_line
line_code.split('_')[2].to_i
end
+ def diff_line
+ if diff
+ @diff_line ||= diff.diff.lines.select { |line| line =~ /\A\+/ }[diff_new_line] ||
+ diff.diff.lines.select { |line| line =~ /\A\-/ }[diff_old_line]
+ end
+ end
+
def discussion_id
@discussion_id ||= [:discussion, noteable_type.try(:underscore), noteable_id || commit_id, line_code].join("-").to_sym
end
diff --git a/app/views/projects/commits/_text_file.html.haml b/app/views/projects/commits/_text_file.html.haml
index bfc3180a84c..3e9a80325b8 100644
--- a/app/views/projects/commits/_text_file.html.haml
+++ b/app/views/projects/commits/_text_file.html.haml
@@ -3,7 +3,7 @@
%a.supp_diff_link Diff suppressed. Click to show
%table.text-file{class: "#{'hide' if too_big}"}
- - each_diff_line(diff, index) do |line, type, line_code, line_new, line_old|
+ - each_diff_line(diff, index) do |line, type, line_code, line_new, line_old, raw_line|
%tr.line_holder{ id: line_code, class: "#{type}" }
- if type == "match"
%td.old_line= "..."
@@ -20,4 +20,4 @@
- if @reply_allowed
- comments = @line_notes.select { |n| n.line_code == line_code }.sort_by(&:created_at)
- unless comments.empty?
- = render "projects/notes/diff_notes_with_reply", notes: comments
+ = render "projects/notes/diff_notes_with_reply", notes: comments, raw_line: raw_line
diff --git a/app/views/projects/notes/_diff_notes_with_reply.html.haml b/app/views/projects/notes/_diff_notes_with_reply.html.haml
index 5a1a945f399..1364ad209b6 100644
--- a/app/views/projects/notes/_diff_notes_with_reply.html.haml
+++ b/app/views/projects/notes/_diff_notes_with_reply.html.haml
@@ -1,11 +1,13 @@
- note = notes.first # example note
-%tr.notes_holder
- %td.notes_line{ colspan: 2 }
- %span.btn.disabled
- %i.icon-comment
- = notes.count
- %td.notes_content
- %ul.notes{ rel: note.discussion_id }
- = render notes
+-# Check if line want not changed since comment was left
+- if !defined?(raw_line) || raw_line == note.diff_line
+ %tr.notes_holder
+ %td.notes_line{ colspan: 2 }
+ %span.btn.disabled
+ %i.icon-comment
+ = notes.count
+ %td.notes_content
+ %ul.notes{ rel: note.discussion_id }
+ = render notes
- = render "projects/notes/discussion_reply_button", note: note
+ = render "projects/notes/discussion_reply_button", note: note