parent
8e329db4d8
commit
b8cccdffda
@ -1,2 +1,13 @@
|
|||||||
module PullRequestsHelper
|
module PullRequestsHelper
|
||||||
|
|
||||||
|
# 获取diff内容行号
|
||||||
|
def diff_line_num content
|
||||||
|
content.scan(/@@ -(\d+),\d+ \+\d+,\d+ @@/).first.nil? ? "" : content.scan(/@@ -(\d+),\d+ \+\d+,\d+ @@/).first.join("").to_i
|
||||||
|
end
|
||||||
|
|
||||||
|
# 处理内容
|
||||||
|
def diff_content content
|
||||||
|
content.gsub!(/.*@@ -\d+,\d+ \+\d+,\d+ @@\n/m,'')
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
@ -1,34 +1,33 @@
|
|||||||
<% @changes.each do |changes| %>
|
<% if @changes %>
|
||||||
<div class="showing-changes-row fontGrey2" style="width:730px; margin:0 -10px;">Showing <a href="javascript:void(0)" class="linkGrey3 fb" id="changed-files">3 changed files</a> with <span class="c_green fb">3 additions</span> and <span class="c_red fb">3 deletions</span>
|
<% @changes.try(:changes).each do |cd| %>
|
||||||
<ol class="mt10" id="changed-files-detail">
|
<div class="showing-changes-row fontGrey2">
|
||||||
<li><a href="javascript:void(0)" class="linkGrey3">app/views/organizations/_org_course_homework.html.erb</a> </li>
|
<a href="javascript:void()" class="linkGrey3" id="changed-files">
|
||||||
<li><a href="javascript:void(0)" class="linkGrey3">app/views/users/_course_homework.html.erb</a> </li>
|
<img src="/images/vlicon/file.png" width="18" height="20" style="vertical-align:middle;" class="mr5" /><%= cd['new_path'] %>
|
||||||
<li><a href="javascript:void(0)" class="linkGrey3">app/views/users/_user_homework_detail.html.erb</a> </li>
|
</a>
|
||||||
</ol>
|
</div>
|
||||||
</div>
|
<div class="autoscroll">
|
||||||
<div class="showing-changes-row fontGrey2" style="width:730px; margin:0 -10px;"><a href="javascript:void(0)" class="linkGrey3"><img src="/images/vlicon/file.png" width="18" height="20" style="vertical-align:middle;" class="mr5" />app/views/organizations/_org_course_homework.html.erb</a></div>
|
<table class="filecontent syntaxhl" style="width:100%;" >
|
||||||
<div class="showing-changes-detail" style="width:750px; margin:0 -10px;">
|
<tbody>
|
||||||
<table class="changes-detail-chart">
|
<% line_num = diff_line_num(cd['diff']) %>
|
||||||
<tr>
|
<% diff_content = diff_content(cd['diff']) %>
|
||||||
<td class="diff-line-number fontGrey2">99</td>
|
<% syntax_highlight_lines('new_path', Redmine::CodesetUtil.to_utf8_by_setting(diff_content)).each do |line| %>
|
||||||
<td class="diff-line-number fontGrey2">99</td>
|
<tr>
|
||||||
<td class="fontGrey2 p10"><% if activity.homework_type == 3 && activity.homework_detail_group.base_on_project == 1 %></td>
|
<th class="line-num" id="L<%= line_num %>" style="vertical-align: top;">
|
||||||
</tr>
|
<a href="#L<%= line_num %>" style="padding-top: 0px;"><%= line_num %></a>
|
||||||
<tr>
|
</th>
|
||||||
<td class="diff-line-number fontGrey2">100</td>
|
<% if line[0,1] == "-" %>
|
||||||
<td class="diff-line-number fontGrey2">100</td>
|
<td class="line-code diff_out"><pre style="width:auto;white-space: nowrap; "><%= line.html_safe %></pre></td>
|
||||||
<td class="fontGrey2 p10"><div class="mt10"></td>
|
<% elsif line[0,1] == "+" %>
|
||||||
</tr>
|
<td class="line-code diff_in"><pre style="width:auto;white-space: nowrap; "><%= line.html_safe %></pre></td>
|
||||||
<tr>
|
<% else%>
|
||||||
<td class="diff-line-number fontGrey2 number-line-old">111</td>
|
<td class="line-code"><pre style="width:auto;white-space: nowrap; "><%= line.html_safe %></pre></td>
|
||||||
<td class="diff-line-number fontGrey2 number-line-old"></td>
|
<% end %>
|
||||||
<td class="fontGrey2 p10 code-line-old">- <div class="fl mr5 fontGrey3"></td>
|
</tr>
|
||||||
</tr>
|
<% line_num += 1 %>
|
||||||
<tr class="code-line-new">
|
<% end %>
|
||||||
<td class="diff-line-number fontGrey2 number-line-new"></td>
|
</tbody>
|
||||||
<td class="diff-line-number fontGrey2 number-line-new">111</td>
|
</table>
|
||||||
<td class="fontGrey2 p10 code-line-new">+ <div class="fl mr20 fontGrey3 w80"></td>
|
</div>
|
||||||
</tr>
|
<% end %>
|
||||||
</table>
|
|
||||||
</div>
|
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
|
@ -1 +1 @@
|
|||||||
$("#merge_record_1").html('<%= render :partial => "pull_requests/pull_request_changes" %>');
|
$("#merge_record_1").html('<%= escape_javascript( render :partial => "pull_requests/pull_request_changes", :locals => {:type => @type} ) %>');
|
Loading…
Reference in new issue