From 515649beb65b9106ef52233efacaf3d18c8d432c Mon Sep 17 00:00:00 2001 From: huang Date: Thu, 4 Aug 2016 15:07:15 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8E=A5=E5=8F=97PR=E5=B1=80=E9=83=A8=E5=88=B7?= =?UTF-8?q?=E6=96=B0=E5=8F=8A=E8=B7=B3=E8=BD=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/pull_requests_controller.rb | 11 ++- app/views/pull_requests/_show.html.erb | 77 ++++++++++--------- .../pull_requests/accept_pull_request.js.erb | 2 + app/views/pull_requests/show.js.erb | 4 +- config/routes.rb | 2 +- 5 files changed, 55 insertions(+), 41 deletions(-) create mode 100644 app/views/pull_requests/accept_pull_request.js.erb diff --git a/app/controllers/pull_requests_controller.rb b/app/controllers/pull_requests_controller.rb index efa060434..2d77c21d4 100644 --- a/app/controllers/pull_requests_controller.rb +++ b/app/controllers/pull_requests_controller.rb @@ -75,10 +75,13 @@ class PullRequestsController < ApplicationController # @param [Integer] id The ID of a merge request. # @return [Gitlab::ObjectifiedHash] def accept_pull_request - commit_id = parmas[:commit_id] - status = @g.accept_merge_rquest(@project.gpid, commit_id) - if status == '200' - # 需跳入的地方 + begin + status = @g.accept_merge_rquest(@project.gpid, params[:id]) + respond_to do |format| + format.js{redirect_to project_pull_request_path(status.id, :project_id => @project.id)} + end + rescue Exception => e + @message = e.message end end diff --git a/app/views/pull_requests/_show.html.erb b/app/views/pull_requests/_show.html.erb index 0ba02d9b4..4aac6193c 100644 --- a/app/views/pull_requests/_show.html.erb +++ b/app/views/pull_requests/_show.html.erb @@ -1,45 +1,52 @@ -
- <%= @request.state == "merged" ? "已合并" : "待处理" %>合并请求 由<%= link_to @request.author.try(:username), user_path(get_user_by_login_and(@request.author.try(:username))), :class => "link-blue" %>于<%= time_tag(@request.created_at) %>提交 · 最后编辑时间<%= time_tag(@request.updated_at) %> - -
+
+ <%= render :partial => "pull_requests/error_message" %>
-
<%= @request.title %>

<%= @request.description %>

-<% if @commits_count == 0 && @changes_count == 0 %> -
- 请求将 <%= @request.source_branch %> 合并至 <%= @request.target_branch %> -
- <%= @request.source_branch %>没有新内容可以合并至<%= @request.target_branch %>
-

请将新改动提交至源分支或者切换到其它目标分支

+ +
+
+ <%= @request.state == "merged" ? "已合并" : "待处理" %>合并请求 由<%= link_to @request.author.try(:username), user_path(get_user_by_login_and(@request.author.try(:username))), :class => "link-blue" %>于<%= time_tag(@request.created_at) %>提交 · 最后编辑时间<%= time_tag(@request.updated_at) %> + +
+
+
<%= @request.title %>

<%= @request.description %>

+ <% if @commits_count == 0 && @changes_count == 0 %> +
+ 请求将 <%= @request.source_branch %> 合并至 <%= @request.target_branch %> +
+ <%= @request.source_branch %>没有新内容可以合并至<%= @request.target_branch %>
+

请将新改动提交至源分支或者切换到其它目标分支

+
-
-<% else %> - <% if @request.state == "merged" %> + <% else %> + <% if @request.state == "merged" %> - 6666 - <% else %> -
- 请求将 <%= @request.source_branch %> 合并至 <%= @request.target_branch %> -
- <%= link_to "接受请求", accept_pull_request_project_pull_request_path(@request.id, :project_id => @project.id), :class => "BlueCirBtn" %> + 6666 + <% else %> +
+ 请求将 <%= @request.source_branch %> 合并至 <%= @request.target_branch %> +
+ <%= link_to "接受请求", accept_pull_request_project_pull_request_path(@request.id, :project_id => @project.id), :remote => true, :class => "BlueCirBtn" %> +
-
- <% end %> -
    -
  • <%= link_to "提交#{@commits_count}".html_safe, pull_request_commits_project_pull_request_path(@request.id, :project_id => @project.id, :type => 1), :remote => true, :class => "active" %>
  • -
  • <%= link_to "改动#{@changes_count}".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" %> -
-
- <%= render :partial => "pull_requests/pull_request_changes" %> -
-<% end %> + <% end %> +
    +
  • <%= link_to "提交#{@commits_count}".html_safe, pull_request_commits_project_pull_request_path(@request.id, :project_id => @project.id, :type => 1), :remote => true, :class => "active" %>
  • +
  • <%= link_to "改动#{@changes_count}".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" %> +
+
+ <%= render :partial => "pull_requests/pull_request_changes" %> +
+ <% end %> +
+