socialforge/app/views/repositories/_change_diff.html.erb

50 lines
2.0 KiB
Plaintext

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<table class="filecontent syntaxhl">
<tbody>
<% diff = ActiveSupport::JSON.decode(change.to_json) %>
<% diff = OpenStruct.new(diff) %>
<% @diff_file = Trustie::Gitlab::Diff::File.new(diff) %>
<% @diff_file.diff_lines.each_with_index do |line, index| %>
<% type = line.type %>
<% last_line = line.new_pos.to_s %>
<% line_old = line.old_pos.to_s %>
<% if type.nil? || type == "match" %>
<tr class="line_holder" >
<td class="old_line">
<a><%= type == "match" ? "..." : line_old.center(4) %></a>
</td>
<td class="new_line" >
<a><%= type == "match" ? "..." : last_line.center(4) %></a>
</td>
<td class="line_content noteable_line <%= 'c_grey' if type == "match" %>" >
<pre style="width:auto;overflow: auto; "><%= Redmine::CodesetUtil.replace_invalid_utf8(line.text).html_safe %></pre>
</td>
</tr>
<% else %>
<% old_line = type == 'new' ? ' '*4: line_old %>
<% new_line = type == 'old' ? ' '*4: last_line %>
<tr class="<%= type == 'old' ? 'line_holder old' : 'line_holder new' %>" >
<td class="old_line">
<a><%= old_line.to_s.center(4) %></a>
</td>
<td class="new_line" data-linenumber="2">
<a><%= new_line.to_s.center(4) %></a>
</td>
<td class="<%= type == 'old' ? 'line_content noteable_line old' : 'line_content new noteable_line' %> " >
<pre style="width:auto;overflow: auto; "><%= Redmine::CodesetUtil.replace_invalid_utf8(line.text).html_safe %></pre>
</td>
</tr>
<% end %>
<% end %>
<tr>
<td class=" old_line " data-linenumber="5">
...
</td>
<td class="new_line " data-linenumber="5">
...
</td>
<td class="line_content "></td>
</tr>
</tbody>
</table>