添加关闭pull request功能

This commit is contained in:
huang 2016-08-08 15:23:55 +08:00
parent fbdb1249c2
commit 518d6bacbe
5 changed files with 35 additions and 4 deletions

View File

@ -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]

View File

@ -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

View File

@ -4,8 +4,10 @@
<div id="pull_request_show">
<div id="mergeShow" class="f14 fontGrey2 merge-show">
<span class="mr10 open-status"><%= @request.state == "merged" ? "已合并" : "待处理" %></span><span class="mr10">合并请求</span> 由<%= 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) %>
<!--<a href="javascript:void(0);" class="BlueCirBtnMini fr mt5">编辑</a>-->
<span class="mr10 open-status"><%= get_state(@request.state) %></span><span class="mr10">合并请求</span> 由<%= 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) %>
<% unless @request.state == "merged" %>
<%= link_to "#{@request.state == 'closed' ? '重新打开' : '关闭'}", update_pull_request_project_pull_request_path(@request.id, :project_id => @project.id, :state => @request.state =="closed" ? "reopen" : "close"), :class => "BlueCirBtn fr" %>
<% end %>
<div class="cl"></div>
</div>
<div class="new-merge-row b_grey"><strong><%= @request.title %></strong><p class="mt10"><%= @request.description %></p></div>

View File

@ -456,4 +456,9 @@ zh:
# 版本库迁移
label_repository_migrate_dec: 注意Trustie版本库近期进行了一次大的改造历史版本需要转换成新的版本输入新的版本库名即可完成转换。 转换过程可能需要等待一段时间。
label_repository_name_dec: 版本库名仅小写字母a-z、数字、破折号-和下划线_可以使用长度必须在 1 到 254 个字符之间,一旦保存,标识无法修改。
label_repository_name_dec: 版本库名仅小写字母a-z、数字、破折号-和下划线_可以使用长度必须在 1 到 254 个字符之间,一旦保存,标识无法修改。
# pull requests
label_state_open: 待处理
label_state_closed: 关闭
label_state_merged: 已合并

View File

@ -816,6 +816,7 @@ RedmineApp::Application.routes.draw do
get 'accept_pull_request'
get 'pull_request_commits'
get 'pull_request_changes'
get 'update_pull_request'
end
end