From 721b75733c49117100a5caf04bf6040fe6004dca Mon Sep 17 00:00:00 2001 From: Marin Jankovski Date: Thu, 4 Sep 2014 14:13:24 +0200 Subject: [PATCH] Take the next type into consideration --- app/helpers/commits_helper.rb | 4 ++-- app/views/projects/commits/_parallel_view.html.haml | 5 +++-- lib/gitlab/diff_parser.rb | 3 ++- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/app/helpers/commits_helper.rb b/app/helpers/commits_helper.rb index fe6c303ecf2..b3249e520a4 100644 --- a/app/helpers/commits_helper.rb +++ b/app/helpers/commits_helper.rb @@ -25,8 +25,8 @@ module CommitsHelper def side_diff_line(diff, index) Gitlab::DiffParser.new(diff.diff.lines.to_a, diff.new_path) - .each do |full_line, type, line_code, line_new, line_old, raw_line, next_line| - yield(full_line, type, line_code, line_new, line_old, raw_line, next_line) + .each do |full_line, type, line_code, line_new, line_old, raw_line, next_type, next_line| + yield(full_line, type, line_code, line_new, line_old, raw_line, next_type, next_line) end end diff --git a/app/views/projects/commits/_parallel_view.html.haml b/app/views/projects/commits/_parallel_view.html.haml index 97e1c884b7b..7debc44e132 100644 --- a/app/views/projects/commits/_parallel_view.html.haml +++ b/app/views/projects/commits/_parallel_view.html.haml @@ -1,7 +1,7 @@ / Side-by-side diff view %div.text-file %table - - side_diff_line(diff, index) do |line, type, line_code, line_new, line_old, raw_line, next_line| + - side_diff_line(diff, index) do |line, type, line_code, line_new, line_old, raw_line, next_type, next_line| %tr.line_holder.parallel{ id: line_code } - if type == "match" = render "projects/commits/diffs/match_line_parallel", {line: line, @@ -25,7 +25,8 @@ %td.new_line{class: "#{type}", data: {linenumber: line_new}} = link_to raw(line_new) , "##{line_code}", id: line_code - if type == 'old' - %td.line_content.parallel{class: "noteable_line new #{line_code}", "line_code" => line_code}= raw next_line + - content = next_type == 'new' ? next_line : " " + %td.line_content.parallel{class: "noteable_line new #{line_code}", "line_code" => line_code}= raw content - else %td.line_content.parallel{class: "#{type}"}= raw line diff --git a/lib/gitlab/diff_parser.rb b/lib/gitlab/diff_parser.rb index f226692a63c..3f402c4c238 100644 --- a/lib/gitlab/diff_parser.rb +++ b/lib/gitlab/diff_parser.rb @@ -38,8 +38,9 @@ module Gitlab next else type = identification_type(line) + next_type = identification_type(next_line) line_code = generate_line_code(new_path, line_new, line_old) - yield(full_line, type, line_code, line_new, line_old, raw_line, next_line) + yield(full_line, type, line_code, line_new, line_old, raw_line, next_type, next_line) end -- GitLab