diff --git a/app/controllers/pull_requests_controller.rb b/app/controllers/pull_requests_controller.rb index 58d1cb3b2..c365a8b37 100644 --- a/app/controllers/pull_requests_controller.rb +++ b/app/controllers/pull_requests_controller.rb @@ -1,7 +1,7 @@ class PullRequestsController < ApplicationController before_filter :find_project_and_repository - before_filter :connect_gitlab, :only => [:index, :show, :create, :accept_pull_request, :pull_request_commits, :pull_request_changes, :new] + before_filter :connect_gitlab, :only => [:index, :show, :create, :accept_pull_request, :pull_request_commits, :pull_request_changes, :new, :update_pull_request] layout "base_projects" include PullRequestsHelper include ApplicationHelper @@ -107,6 +107,18 @@ class PullRequestsController < ApplicationController end end + # 更新请求的状态state => cloesed + def update_pull_request + begin + @g.update_merge_request(@project.gpid, params[:id], :state_event => params[:state]) + respond_to do |format| + format.html{redirect_to project_pull_request_path(params[:id], :project_id => @project.id)} + end + rescue Exception => e + @message = e.message + end + end + # 获取某次请求的提交次数 def pull_request_commits @type = parms[:type] diff --git a/app/helpers/pull_requests_helper.rb b/app/helpers/pull_requests_helper.rb index 82d4edc0f..c33100ea8 100644 --- a/app/helpers/pull_requests_helper.rb +++ b/app/helpers/pull_requests_helper.rb @@ -14,4 +14,15 @@ module PullRequestsHelper User.find(user_id).try(:login) end + def get_state state + case state + when "open","reopened" + l(:label_state_open) + when "closed" + l(:label_state_closed) + when "merged" + l(:label_state_merged) + end + end + end diff --git a/app/views/pull_requests/_show.html.erb b/app/views/pull_requests/_show.html.erb index 7bcf296a3..bb3cefc9f 100644 --- a/app/views/pull_requests/_show.html.erb +++ b/app/views/pull_requests/_show.html.erb @@ -4,8 +4,10 @@
<%= @request.description %>