[refs #90] add commit/pull lines ref
This commit is contained in:
parent
b24a4a35b2
commit
35b953ac11
|
@ -1183,4 +1183,8 @@ table.tablesorter tr td.no_results {
|
|||
|
||||
.label-bootstrap.label-info.font14 a {
|
||||
color: #FFFFFF;
|
||||
}
|
||||
|
||||
.line_numbers a {
|
||||
color: #999999;
|
||||
}
|
|
@ -1,14 +1,18 @@
|
|||
# -*- encoding : utf-8 -*-
|
||||
module DiffHelper
|
||||
|
||||
def render_diff(diff)
|
||||
def render_diff(diff, diff_counter)
|
||||
diff_display ||= Diff::Display::Unified.new(diff.diff)
|
||||
|
||||
path = if @pull
|
||||
"#{polymorphic_path [@project, @pull]}/diff"
|
||||
elsif @commit
|
||||
"#{commit_path @project, @commit}"
|
||||
end
|
||||
#res = "<a name='#{h(diff.a_path)}'></a>"
|
||||
|
||||
res = "<table class='diff inline' cellspacing='0' cellpadding='0'>"
|
||||
res += "<tbody>"
|
||||
res += diff_display.render(Git::Diff::InlineCallback.new)
|
||||
res += diff_display.render(Git::Diff::InlineCallback.new(diff_counter, path))
|
||||
res += "</tbody>"
|
||||
res += "</table>"
|
||||
|
||||
|
|
|
@ -7,4 +7,4 @@
|
|||
.r= link_to "view file @ #{short_hash_id(commit_id)}", blob_path(@project, commit_id, commit_diff.b_path)
|
||||
.clear
|
||||
|
||||
.diff_data= render_diff(commit_diff) unless (@git_repository.tree(commit_id) / commit_diff.b_path).binary?
|
||||
.diff_data= render_diff(commit_diff, commit_diff_counter) unless (@git_repository.tree(commit_id) / commit_diff.b_path).binary?
|
|
@ -6,5 +6,4 @@
|
|||
- if pull_diff.b_path.present?
|
||||
.r= link_to "view file @ #{short_hash_id(commit_id)}", blob_path(@project, commit_id, pull_diff.b_path)
|
||||
.clear
|
||||
|
||||
.diff_data= render_diff(pull_diff) unless (Git::Repository.new(@pull.path).tree(commit_id) / pull_diff.b_path).binary?
|
||||
.diff_data= render_diff(pull_diff, pull_diff_counter) unless (Git::Repository.new(@pull.path).tree(commit_id) / pull_diff.b_path).binary?
|
||||
|
|
|
@ -2,6 +2,11 @@
|
|||
module Git
|
||||
module Diff
|
||||
class InlineCallback < ::Diff::Renderer::Base
|
||||
def initialize diff_counter, path
|
||||
@diff_counter = diff_counter
|
||||
@path = path
|
||||
end
|
||||
|
||||
def before_headerblock(block)
|
||||
end
|
||||
|
||||
|
@ -17,33 +22,39 @@ module Git
|
|||
end
|
||||
|
||||
def addline(line)
|
||||
id = "F#{@diff_counter}R#{line.new_number}"
|
||||
"<tr class='changes'>
|
||||
<td class='line_numbers'></td>
|
||||
<td class='line_numbers'>#{line.new_number}</td>
|
||||
<td class='line_numbers' id='#{id}'><a href='#{@path}##{id}'>#{line.new_number}</a></td>
|
||||
<td class='code ins'><pre>#{render_line(line)}</pre></td>
|
||||
</tr>"
|
||||
end
|
||||
|
||||
def remline(line)
|
||||
id = "F#{@diff_counter}L#{line.old_number}"
|
||||
"<tr class='changes'>
|
||||
<td class='line_numbers'>#{line.old_number}</td>
|
||||
<td class='line_numbers' id='#{id}'><a href='#{@path}##{id}'>#{line.old_number}</a></td>
|
||||
<td class='line_numbers'></td>
|
||||
<td class='code del'><pre>#{render_line(line)}</pre></td>
|
||||
</tr>"
|
||||
end
|
||||
|
||||
def modline(line)
|
||||
rid = "F#{@diff_counter}R#{line.new_number}"
|
||||
lid = "F#{@diff_counter}L#{line.old_number}"
|
||||
"<tr clas='chanes line'>
|
||||
<td class='line_numbers'>#{line.old_number}</td>
|
||||
<td class='line_numbers'>#{line.new_number}</td>
|
||||
<td class='line_numbers' id='#{lid}'><a href='#{@path}##{lid}'>#{line.old_number}</a></td>
|
||||
<td class='line_numbers' id='#{rid}'><a href='#{@path}##{rid}'>#{line.new_number}</a></td>
|
||||
<td class='code unchanged modline'><pre>#{render_line(line)}</pre></td>
|
||||
</tr>"
|
||||
end
|
||||
|
||||
def unmodline(line)
|
||||
rid = "F#{@diff_counter}R#{line.new_number}"
|
||||
lid = "F#{@diff_counter}L#{line.old_number}"
|
||||
"<tr class='changes unmodline'>
|
||||
<td class='line_numbers'>#{line.old_number}</td>
|
||||
<td class='line_numbers'>#{line.new_number}</td>
|
||||
<td class='line_numbers' id='#{lid}'><a href='#{@path}##{lid}'>#{line.old_number}</a></td>
|
||||
<td class='line_numbers' id='#{rid}'><a href='#{@path}##{rid}'>#{line.new_number}</a></td>
|
||||
<td class='code unchanged unmodline'><pre>#{render_line(line)}</pre></td>
|
||||
</tr>"
|
||||
end
|
||||
|
@ -57,9 +68,11 @@ module Git
|
|||
end
|
||||
|
||||
def nonewlineline(line)
|
||||
rid = "F#{@diff_counter}R#{line.new_number}"
|
||||
lid = "F#{@diff_counter}L#{line.old_number}"
|
||||
"<tr class='changes'>
|
||||
<td class='line_numbers'>#{line.old_number}</td>
|
||||
<td class='line_numbers'>#{line.new_number}</td>
|
||||
<td class='line_numbers' id='#{lid}'><a href='#{@path}##{lid}'>#{line.old_number}</a></td>
|
||||
<td class='line_numbers' id='#{rid}'><a href='#{@path}##{rid}'>#{line.new_number}</a></td>
|
||||
<td class='code modline unmodline'><pre>#{render_line(line)}</pre></td>
|
||||
</tr>"
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue