From 3df8a4663441aba3c8ba36ec3549402e0f549ba9 Mon Sep 17 00:00:00 2001 From: huang Date: Thu, 11 Aug 2016 14:16:13 +0800 Subject: [PATCH] =?UTF-8?q?PUll=20request=E4=BB=A3=E7=A0=81=E7=AE=80?= =?UTF-8?q?=E5=8C=96=E5=8F=8Areverse=E8=AF=84=E8=AE=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/pull_requests_controller.rb | 6 ++- .../_pull_request_changes.html.erb | 2 +- .../_pull_request_comments.html.erb | 2 +- .../_pull_request_commits.html.erb | 45 ++++++++++--------- app/views/pull_requests/_show.html.erb | 15 ++++--- 5 files changed, 39 insertions(+), 31 deletions(-) diff --git a/app/controllers/pull_requests_controller.rb b/app/controllers/pull_requests_controller.rb index 2592421a6..56dc0839f 100644 --- a/app/controllers/pull_requests_controller.rb +++ b/app/controllers/pull_requests_controller.rb @@ -95,7 +95,7 @@ class PullRequestsController < ApplicationController @commits_count = @commits.count @changes = @g.merge_request_changes(@project.gpid, params[:id]).try(:changes) @changes_count = @changes.count - @comments = @g.merge_request_comments(@project.gpid, params[:id]) + @comments = @g.merge_request_comments(@project.gpid, params[:id]).reverse @comments_count = @comments.count @limit = 10 @@ -178,7 +178,7 @@ class PullRequestsController < ApplicationController # Gitlab.merge_request_comments(5, 1) def pull_request_comments begin - @comments = @g.merge_request_comments(@project.gpid, params[:id]) + @comments = @g.merge_request_comments(@project.gpid, params[:id]).reverse @comments_count = @comments.count @limit = 10 @@ -198,6 +198,7 @@ class PullRequestsController < ApplicationController # merge_request_id (required) - The ID of MR def pull_request_commits begin + @type = params[:type] @commits = @g.merge_request_commits(@project.gpid, params[:id]) @commits_count = @commits.count @@ -218,6 +219,7 @@ class PullRequestsController < ApplicationController # merge_request_id (required) - The ID of MR def pull_request_changes begin + @type = params[:type] @changes = @g.merge_request_changes(@project.gpid, params[:id]).try(:changes) @changes_count = @changes.count diff --git a/app/views/pull_requests/_pull_request_changes.html.erb b/app/views/pull_requests/_pull_request_changes.html.erb index d56702533..07e891ec6 100644 --- a/app/views/pull_requests/_pull_request_changes.html.erb +++ b/app/views/pull_requests/_pull_request_changes.html.erb @@ -1,4 +1,4 @@ -<% unless @changes.blank? %> +<% if !@changes.blank? && @type == "3" %> <% @changes.each do |cd| %>
diff --git a/app/views/pull_requests/_pull_request_comments.html.erb b/app/views/pull_requests/_pull_request_comments.html.erb index 2a02cb8db..9208a13ad 100644 --- a/app/views/pull_requests/_pull_request_comments.html.erb +++ b/app/views/pull_requests/_pull_request_comments.html.erb @@ -5,7 +5,7 @@ 提交请求 <% end %>
-<% @comments.reverse.each do |comment| %> +<% @comments.each do |comment| %>
<%= link_to comment.author.try(:username), user_path(get_user_by_login_and(comment.author.try(:username))), :class => "link-blue mr15 fl" %> <%= time_tag(comment.created_at) %>前 diff --git a/app/views/pull_requests/_pull_request_commits.html.erb b/app/views/pull_requests/_pull_request_commits.html.erb index 44670f91f..0351f6919 100644 --- a/app/views/pull_requests/_pull_request_commits.html.erb +++ b/app/views/pull_requests/_pull_request_commits.html.erb @@ -1,29 +1,32 @@
根据最近提交时间排列
-<% @commits.each do |commit| %> -
-
- <%= format_date(commit.created_at) %> - -

<%= link_to commit.author_name, user_path(get_user_by_mail(commit.author_email)), :class => "link-blue" %> 创建于<%= time_tag(commit.created_at) %>前

-
-
- <%= commit.title %> +<% if !@commits.blank? && @type == "2" %> + <% @commits.each do |commit| %> +
+
+ <%= format_date(commit.created_at) %> + +

<%= link_to commit.author_name, user_path(get_user_by_mail(commit.author_email)), :class => "link-blue" %> 创建于<%= time_tag(commit.created_at) %>前

+
+
+ <%= commit.title %> -
-
+
+
<%= link_to truncate(commit.short_id, :length => 20), {:controller => 'repositories', :action => 'commit_diff', :id => @project.id, :changeset => commit.id}, :target => "_blank" %> +
+
+
+ <% end %> +
+
+
    + <%= pagination_links_full @pages, @count, :per_page_links => false, :remote => @is_remote, :flag => true, :is_new => true%> +
+
+
-
-
<% end %> -
-
-
    - <%= pagination_links_full @pages, @count, :per_page_links => false, :remote => @is_remote, :flag => true, :is_new => true%> -
-
-
-
+ diff --git a/app/views/pull_requests/_show.html.erb b/app/views/pull_requests/_show.html.erb index d792dc823..3edb9c874 100644 --- a/app/views/pull_requests/_show.html.erb +++ b/app/views/pull_requests/_show.html.erb @@ -40,19 +40,22 @@
-
- <%= render :partial => "pull_requests/pull_request_comments" %> -
+ <% if @type == nil || @type == "1" %> +
+ <%= render :partial => "pull_requests/pull_request_comments" %> +
+ <% end %>
<%= render :partial => "pull_requests/pull_request_commits" %>
<%= render :partial => "pull_requests/pull_request_changes" %>
+ <% end %>