line links for commit diff, css fixed for line diff
This commit is contained in:
parent
b60b7b2e2b
commit
570f63daaf
7 changed files with 133 additions and 80 deletions
|
@ -1,7 +1,7 @@
|
|||
.file_stats
|
||||
= render "commits/diff_head"
|
||||
|
||||
- @commit.diffs.each do |diff|
|
||||
- @commit.diffs.each_with_index do |diff, i|
|
||||
- next if diff.diff.empty?
|
||||
- file = (@commit.tree / diff.b_path)
|
||||
- next unless file
|
||||
|
@ -15,7 +15,7 @@
|
|||
%br/
|
||||
.diff_file_content
|
||||
- if file.text?
|
||||
= render :partial => "commits/text_file", :locals => { :diff => diff }
|
||||
= render :partial => "commits/text_file", :locals => { :diff => diff, :index => i }
|
||||
- elsif file.image?
|
||||
.diff_file_content_image
|
||||
%img{:src => "data:#{file.mime_type};base64,#{Base64.encode64(file.data)}"}
|
||||
|
|
|
@ -1,29 +1,26 @@
|
|||
%table
|
||||
%thead
|
||||
%th Files
|
||||
%ul.bordered-list
|
||||
- @commit.diffs.each do |diff|
|
||||
%tr
|
||||
%td
|
||||
- if diff.deleted_file
|
||||
%span.removed_file
|
||||
%a{:href => "##{diff.a_path}"}
|
||||
= diff.a_path
|
||||
= image_tag "blueprint_delete.png"
|
||||
- elsif diff.renamed_file
|
||||
%span.moved_file
|
||||
%a{:href => "##{diff.b_path}"}
|
||||
= diff.a_path
|
||||
= "->"
|
||||
= diff.b_path
|
||||
= image_tag "blueprint_notice.png"
|
||||
- elsif diff.new_file
|
||||
%span.new_file
|
||||
%a{:href => "##{diff.b_path}"}
|
||||
= diff.b_path
|
||||
= image_tag "blueprint_add.png"
|
||||
- else
|
||||
%span.edit_file
|
||||
%a{:href => "##{diff.b_path}"}
|
||||
= diff.b_path
|
||||
= image_tag "blueprint_info.png"
|
||||
%li
|
||||
- if diff.deleted_file
|
||||
%span.removed_file
|
||||
%a{:href => "##{diff.a_path}"}
|
||||
= diff.a_path
|
||||
= image_tag "blueprint_delete.png"
|
||||
- elsif diff.renamed_file
|
||||
%span.moved_file
|
||||
%a{:href => "##{diff.b_path}"}
|
||||
= diff.a_path
|
||||
= "->"
|
||||
= diff.b_path
|
||||
= image_tag "blueprint_notice.png"
|
||||
- elsif diff.new_file
|
||||
%span.new_file
|
||||
%a{:href => "##{diff.b_path}"}
|
||||
= diff.b_path
|
||||
= image_tag "blueprint_add.png"
|
||||
- else
|
||||
%span.edit_file
|
||||
%a{:href => "##{diff.b_path}"}
|
||||
= diff.b_path
|
||||
= image_tag "blueprint_info.png"
|
||||
|
||||
|
|
|
@ -1,21 +1,28 @@
|
|||
- line_old = 0
|
||||
- line_new = 0
|
||||
- lines_arr = diff.diff.lines.to_a
|
||||
- lines_arr.each do |line|
|
||||
- line = encode(line)
|
||||
- next if line.match(/^--- \/dev\/null/)
|
||||
- next if line.match(/^--- a/)
|
||||
- next if line.match(/^\+\+\+ b/)
|
||||
- if line.match(/^@@ -/)
|
||||
- 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
|
||||
%table
|
||||
- line_old = 0
|
||||
- line_new = 0
|
||||
- lines_arr = diff.diff.lines.to_a
|
||||
- lines_arr.each do |line|
|
||||
- line = encode(line)
|
||||
- next if line.match(/^--- \/dev\/null/)
|
||||
- next if line.match(/^--- a/)
|
||||
- next if line.match(/^\+\+\+ b/)
|
||||
- if line.match(/^@@ -/)
|
||||
- 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
|
||||
|
||||
= diff_line(line, line_new, line_old)
|
||||
- if line[0] == "+"
|
||||
- line_new += 1
|
||||
- elsif line[0] == "-"
|
||||
- line_old += 1
|
||||
- else
|
||||
- line_new += 1
|
||||
- line_old += 1
|
||||
- full_line = html_escape(line.gsub(/\n/, ''))
|
||||
%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)}= raw "#{full_line} "
|
||||
- if line[0] == "+"
|
||||
- line_new += 1
|
||||
- elsif line[0] == "-"
|
||||
- line_old += 1
|
||||
- else
|
||||
- line_new += 1
|
||||
- line_old += 1
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue