summaryrefslogtreecommitdiff
path: root/app/helpers/diff_helper.rb
diff options
context:
space:
mode:
authorMarin Jankovski <marin@gitlab.com>2014-09-12 18:43:44 +0200
committerMarin Jankovski <marin@gitlab.com>2014-09-12 18:44:53 +0200
commit5564fe31491a8a584b66feb6097742ec4025b8fa (patch)
tree87cfd197e994c182b901453b7076250874447010 /app/helpers/diff_helper.rb
parent29f990002c6e2704bb25ba4aa89491f319699202 (diff)
downloadgitlab-ce-5564fe31491a8a584b66feb6097742ec4025b8fa.tar.gz
Add comments on the side-by-side diff.
Diffstat (limited to 'app/helpers/diff_helper.rb')
-rw-r--r--app/helpers/diff_helper.rb12
1 files changed, 9 insertions, 3 deletions
diff --git a/app/helpers/diff_helper.rb b/app/helpers/diff_helper.rb
index afe7447d4e2..8332b86d485 100644
--- a/app/helpers/diff_helper.rb
+++ b/app/helpers/diff_helper.rb
@@ -49,14 +49,16 @@ module DiffHelper
next_line = diff_file.next_line(line.index)
if next_line
+ next_line_code = generate_line_code(diff_file.file_path, next_line)
next_type = next_line.type
next_line = next_line.text
end
- line = [type, line_old, full_line, line_code, next_type, line_new]
+ line = [type, line_old, full_line, line_code, next_line_code, next_type, line_new]
+
if type == 'match' || type.nil?
# line in the right panel is the same as in the left one
- line = [type, line_old, full_line, line_code, type, line_new, full_line]
+ line = [type, line_old, full_line, line_code, line_code, type, line_new, full_line]
lines.push(line)
elsif type == 'old'
if next_type == 'new'
@@ -78,7 +80,7 @@ module DiffHelper
next
else
# Change is only on the right side, left side has no change
- line = [nil, nil, "&nbsp;", line_code, type, line_new, full_line]
+ line = [nil, nil, "&nbsp;", line_code, line_code, type, line_new, full_line]
lines.push(line)
end
end
@@ -97,4 +99,8 @@ module DiffHelper
line
end
end
+
+ def line_comments
+ @line_comments ||= @line_notes.group_by(&:line_code)
+ end
end