Blob of Support/app/views/diff/_diff_result.html.erb (raw blob data)

1 <%
2 file_path_right = diff_result[:right][:file_path]
3 start_line_right = diff_result[:right][:ln_start]
4
5 open_links = {}
6 files = [:left, :right].map do |lr|
7 file_path = diff_result[lr][:file_path]
8 next "(none)" unless file_path
9
10 side_revision = case
11 when revision.blank? && lr == :right
12 nil
13 when revision.blank? && lr == :left
14 "HEAD"
15 when revision
16 lr == :left ? "#{revision}^" : revision
17 end
18 open_links[lr] = link_to_remote(lr, :params => { :controller => "log", :action => "open_revision", :file_path => file_path, :revision => side_revision, :line => diff_result[lr][:ln_start], :git_path => git.path })
19
20 file_path_right ? link_to_relative_file(git, file_path_right, start_line_right) : git.root_relative_path_for(file_path)
21 end
22 %>
23
24 <h4><%= files.uniq * ' --&gt; ' %></h4>
25 <table class='codediff inline'>
26 <thead>
27 <tr>
28 <td class='line-numbers'><%= open_links[:left] %></td>
29 <td class='line-numbers'><%= open_links[:right] %></td>
30 <td/>
31 </tr>
32 </thead>
33 <tbody>
34 <% diff_result[:lines].each do |line|
35 next if @diff_line_count >= Git::DEFAULT_DIFF_LIMIT
36 @diff_line_count += 1
37 line_num_class, row_class = case line[:type]
38 when :deletion then ["", "del"]
39 when :insertion then ["", "ins"]
40 when :eof then ["line-num-eof", "eof"]
41 when :cut then ["line-num-cut", "cut-line"]
42 else
43 ["", "unchanged"]
44 end
45 %>
46 <tr>
47 <td class="line-numbers <%= line_num_class %>"><%= line[:ln_left] %></td>
48 <td class="line-numbers <%= line_num_class %>"><%= line[:ln_right] %></td>
49 <td class="code <%= row_class %>"><%= htmlize(line[:text]) %></td></tr>
50 <% end %>
51 </tbody>
52 </table>