Commit b54f2393 authored by Marin Jankovski's avatar Marin Jankovski

Parallel diff in two columns.

parent de6f4c31
/ Side-by-side diff view / Side-by-side diff view
- old_lines, new_lines = parallel_diff_lines(project, @commit, diff, file)
- num_lines = old_lines.length
%div.text-file %div.text-file
%table %table
- num_lines.times do |index| - each_diff_line(diff, index) do |line, type, line_code, line_new, line_old, raw_line, e|
- new_line = new_lines[index] %tr.line_holder.parallel{ id: line_code, class: "#{type}" }
- old_line = old_lines[index] - if type != 'match'
%tr.line_holder.parallel %td.old_line
-# For old line = link_to raw(type == "new" ? " " : line_old), "##{line_code}", id: line_code
- if old_line.type == :file_created - if type == 'old'
%td.old_line= old_line.num %td.line_content{class: "parallel noteable_line old #{line_code}", "line_code" => line_code}= line
%td.line_content.parallel= "File was created" - else
- elsif old_line.type == :deleted %td.line_content.parallel= line
%td.old_line.old= old_line.num %td.new_line{data: {linenumber: line_new}}
%td.line_content{class: "parallel noteable_line old #{old_line.code}", "line_code" => old_line.code}= old_line.content = link_to raw(type == "old" ? " " : line_new) , "##{line_code}", id: line_code
- else old_line.type == :no_change - if type == 'new'
%td.old_line= old_line.num %td.line_content.parallel{class: "noteable_line #{type} #{line_code}", "line_code" => line_code}= line
%td.line_content.parallel= old_line.content - else
%td.line_content.parallel= line
-# For new line
- if new_line.type == :file_deleted
%td.new_line= new_line.num
%td.line_content.parallel= "File was deleted"
- elsif new_line.type == :added
%td.new_line.new= new_line.num
%td.line_content{class: "parallel noteable_line new #{new_line.code}", "line_code" => new_line.code}= new_line.content
- else new_line.type == :no_change
%td.new_line= new_line.num
%td.line_content.parallel= new_line.content
- if @reply_allowed
- comments1 = @line_notes.select { |n| n.line_code == old_line.code }.sort_by(&:created_at)
- comments2 = @line_notes.select { |n| n.line_code == new_line.code }.sort_by(&:created_at)
- unless comments1.empty? and comments2.empty?
= render "projects/notes/diff_notes_with_reply_parallel", notes1: comments1, notes2: comments2
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