diff options
author | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2012-01-25 23:10:09 +0400 |
---|---|---|
committer | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2012-01-25 23:10:09 +0400 |
commit | b4cc04d7e17eeefe6d89bbb72661a43d7d9e3e2e (patch) | |
tree | dbfb3d07b1462e7f09a7717596f8748519af8474 /app/views/commits/_text_file.html.haml | |
parent | 73efb837913ee0892c3ab92700a61783397ca83a (diff) |
Commit diff fixes, per-line comments fixed
Diffstat (limited to 'app/views/commits/_text_file.html.haml')
-rw-r--r-- | app/views/commits/_text_file.html.haml | 51 |
1 files changed, 15 insertions, 36 deletions
diff --git a/app/views/commits/_text_file.html.haml b/app/views/commits/_text_file.html.haml index 513efdf02d9..bff578c0e44 100644 --- a/app/views/commits/_text_file.html.haml +++ b/app/views/commits/_text_file.html.haml @@ -1,38 +1,17 @@ %table - - line_old = 0 - - line_new = 0 - - diff_str = diff.diff - - lines_arr = diff_str.lines.to_a - - lines_arr.each do |line| - - next if line.match(/^--- \/dev\/null/) - - next if line.match(/^--- a/) - - next if line.match(/^\+\+\+ b/) - - if line.match(/^@@ -/) - - unless line_old.zero? && line_new.zero? - %tr.line_holder - %td.old_line= "..." - %td.new_line= "..." - %td.line_content - - - line_old = line.match(/\-[0-9]*/)[0].to_i.abs rescue 0 - - line_new = line.match(/\+[0-9]*/)[0].to_i.abs rescue 0 - - next - - - full_line = html_escape(line.gsub(/\n/, '')) + - each_diff_line(diff.diff.lines.to_a, index) do |line, type, line_code, line_new, line_old| %tr.line_holder - %td.old_line - = link_to raw(diff_line_class(line) == "new" ? " " : line_old), "#OLD#{index}-#{line_old}", :id => "OLD#{index}-#{line_old}" - %td.new_line - = link_to raw(diff_line_class(line) == "old" ? " " : line_new) , "#NEW#{index}-#{line_new}", :id => "NEW#{index}-#{line_new}" - %td.line_content{:class => "#{diff_line_class(full_line)} #{build_line_code(line, index, line_new, line_old)}", "line_code" => build_line_code(line, index, line_new, line_old)}= raw "#{full_line} " - - comments = @line_notes.select { |n| n.for_line?(index, line_old, line_new) }.sort_by(&:created_at).reverse - - unless comments.empty? - - comments.each do |note| - = render "notes/per_line_show", :note => note - - if line[0] == "+" - - line_new += 1 - - elsif line[0] == "-" - - line_old += 1 - - else - - line_new += 1 - - line_old += 1 + - if type == "match" + %td.old_line= "..." + %td.new_line= "..." + %td.line_content + - else + %td.old_line= link_to raw(type == "new" ? " " : line_old), "##{line_code}", :id => line_code + %td.new_line= link_to raw(type == "old" ? " " : line_new) , "##{line_code}", :id => line_code + %td.line_content{:class => "noteable_line #{type} #{line_code}", "line_code" => line_code}= raw "#{line} " + + - comments = @line_notes.select { |n| n.line_code == line_code }.sort_by(&:created_at).reverse + - unless comments.empty? + - comments.each do |note| + = render "notes/per_line_show", :note => note + - @line_notes.reject!{ |n| n == note } |