Commit a224a655 authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Merge branch 'mr-commit-comment-diff-lines' into 'master'

Fix commit comments on first line of diff not rendering in Merge Request Discussion view.

Example can be seen near the bottom on this MR: !1533.

Before:

![Screen Shot 2015-02-20 at 10.24.34](https://dev.gitlab.org/uploads/gitlab/gitlabhq/35600b98b5/Screen_Shot_2015-02-20_at_10.24.34.png)

After: the [note](https://dev.gitlab.org/gitlab/gitlabhq/merge_requests/1533/diffs#note_36449) is actually rendered.

See merge request !1552
parents 5484acd9 0632e85c
v 7.9.0 (unreleased) v 7.9.0 (unreleased)
- Move labels/milestones tabs to sidebar - Move labels/milestones tabs to sidebar
- Improve UI for commits, issues and merge request lists - Improve UI for commits, issues and merge request lists
- Fix commit comments on first line of diff not rendering in Merge Request Discussion view.
v 7.8.0 (unreleased) v 7.8.0 (unreleased)
- Fix access control and protection against XSS for note attachments and other uploads. - Fix access control and protection against XSS for note attachments and other uploads.
......
...@@ -409,19 +409,19 @@ class Note < ActiveRecord::Base ...@@ -409,19 +409,19 @@ class Note < ActiveRecord::Base
prev_lines = [] prev_lines = []
diff_lines.each do |line| diff_lines.each do |line|
if generate_line_code(line) != self.line_code if line.type == "match"
if line.type == "match" prev_lines.clear
prev_lines.clear prev_match_line = line
prev_match_line = line
else
prev_lines.push(line)
prev_lines.shift if prev_lines.length >= max_number_of_lines
end
else else
prev_lines << line prev_lines << line
return prev_lines
break if generate_line_code(line) == self.line_code
prev_lines.shift if prev_lines.length >= max_number_of_lines
end end
end end
prev_lines
end end
def diff_lines def diff_lines
......
...@@ -27,7 +27,7 @@ module Gitlab ...@@ -27,7 +27,7 @@ module Gitlab
line_old = line.match(/\-[0-9]*/)[0].to_i.abs rescue 0 line_old = line.match(/\-[0-9]*/)[0].to_i.abs rescue 0
line_new = line.match(/\+[0-9]*/)[0].to_i.abs rescue 0 line_new = line.match(/\+[0-9]*/)[0].to_i.abs rescue 0
next if line_old == 1 && line_new == 1 #top of file next if line_old <= 1 && line_new <= 1 #top of file
lines_obj << Gitlab::Diff::Line.new(full_line, type, line_obj_index, line_old, line_new) lines_obj << Gitlab::Diff::Line.new(full_line, type, line_obj_index, line_old, line_new)
line_obj_index += 1 line_obj_index += 1
next next
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment