diff --git a/app/controllers/pull_requests_controller.rb b/app/controllers/pull_requests_controller.rb
index 808459665..87cd9ac23 100644
--- a/app/controllers/pull_requests_controller.rb
+++ b/app/controllers/pull_requests_controller.rb
@@ -48,6 +48,7 @@ class PullRequestsController < ApplicationController
end
def show
+ @type = params[:type]
@request = @g.merge_request(@project.gpid, params[:id])
@commits = @g.merge_request_commits(@project.gpid, params[:id].to_i)
end
@@ -72,12 +73,12 @@ class PullRequestsController < ApplicationController
# 获取某次请求的提交次数
def pull_request_commits
+ @type = parms[:type]
@commits = @g.merge_request_commits(@project.gpid, params[:id].to_i)
end
# 获取某次请求的改动
def pull_request_changes
- @type = 2
@changes = @g.merge_request_changes(@project.gpid, params[:id])
end
diff --git a/app/helpers/pull_requests_helper.rb b/app/helpers/pull_requests_helper.rb
index fa8554854..e9446e654 100644
--- a/app/helpers/pull_requests_helper.rb
+++ b/app/helpers/pull_requests_helper.rb
@@ -1,2 +1,13 @@
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
diff --git a/app/views/pull_requests/_pull_request_changes.html.erb b/app/views/pull_requests/_pull_request_changes.html.erb
index b1abe1383..66ce993e5 100644
--- a/app/views/pull_requests/_pull_request_changes.html.erb
+++ b/app/views/pull_requests/_pull_request_changes.html.erb
@@ -1,34 +1,33 @@
-<% @changes.each do |changes| %>
-
-
-
-
-
- 99 |
- 99 |
- <% if activity.homework_type == 3 && activity.homework_detail_group.base_on_project == 1 %> |
-
-
- 100 |
- 100 |
- <div class="mt10"> |
-
-
- 111 |
- |
- - <div class="fl mr5 fontGrey3"> |
-
-
- |
- 111 |
- + <div class="fl mr20 fontGrey3 w80"> |
-
-
-
+<% if @changes %>
+ <% @changes.try(:changes).each do |cd| %>
+
+
+ <% end %>
<% end %>
+
diff --git a/app/views/pull_requests/pull_request_changes.js.erb b/app/views/pull_requests/pull_request_changes.js.erb
index 10374c213..2b3d77537 100644
--- a/app/views/pull_requests/pull_request_changes.js.erb
+++ b/app/views/pull_requests/pull_request_changes.js.erb
@@ -1 +1 @@
-$("#merge_record_1").html('<%= render :partial => "pull_requests/pull_request_changes" %>');
\ No newline at end of file
+$("#merge_record_1").html('<%= escape_javascript( render :partial => "pull_requests/pull_request_changes", :locals => {:type => @type} ) %>');
\ No newline at end of file
diff --git a/app/views/pull_requests/show.html.erb b/app/views/pull_requests/show.html.erb
index 634ed2916..fa84102bd 100644
--- a/app/views/pull_requests/show.html.erb
+++ b/app/views/pull_requests/show.html.erb
@@ -12,18 +12,16 @@
- - <%= link_to "提交1".html_safe, pull_request_commits_project_pull_request_path(@request.id, :project_id => @project.id), :remote => true, :class => "active" %>
- - <%= link_to "改动1".html_safe, pull_request_changes_project_pull_request_path(@request.id, :project_id => @project.id), :remote => true, :class => "active" %>
+ - <%= link_to "提交1".html_safe, pull_request_commits_project_pull_request_path(@request.id, :project_id => @project.id, :type => 1), :remote => true, :class => "active" %>
+ - <%= link_to "改动1".html_safe, pull_request_changes_project_pull_request_path(@request.id, :project_id => @project.id, :type => 2), :remote => true %>
根据最近提交时间排列
<%= render :partial => "pull_requests/pull_request_commits" %>
-<% if @type == 2 %>
-
- <%= render :partial => "pull_requests/pull_request_changes" %>
-
-<% end %>
+
+ <%= render :partial => "pull_requests/pull_request_changes" %>
+