版本406异常处理,pull request 冲突接受后406异常提醒
This commit is contained in:
parent
5b93bf2b4d
commit
5527adb795
|
@ -188,15 +188,21 @@ class PullRequestsController < ApplicationController
|
|||
# @return [Gitlab::ObjectifiedHash]
|
||||
def accept_pull_request
|
||||
begin
|
||||
status = @g.accept_merge_rquest(@project.gpid, params[:id], User.current.gid)
|
||||
@status = @g.accept_merge_rquest(@project.gpid, params[:id], User.current.gid)
|
||||
# 接受后,给用户发消息
|
||||
send_message_to_author(@project.id, status.author.try(:username), params[:id], 2)
|
||||
send_message_to_author(@project.id, @status.author.try(:username), params[:id], 2)
|
||||
|
||||
respond_to do |format|
|
||||
format.js{redirect_to project_pull_request_path(status.id, :project_id => @project.id)}
|
||||
format.js{redirect_to project_pull_request_path(@status.id, :project_id => @project.id)}
|
||||
end
|
||||
rescue Gitlab::Error::Forbidden => e
|
||||
@message = l(:label_pull_request_forbidden)
|
||||
rescue Gitlab::Error::DataNotAccepted => e
|
||||
@message = l(:label_pull_request_datanotaccepted)
|
||||
rescue Gitlab::Error::NotFound => e
|
||||
@message = l(:label_pull_request_notfound)
|
||||
rescue Exception => e
|
||||
@message = e.message
|
||||
puts e
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -34,7 +34,9 @@
|
|||
改动已合并至 <%= @request.target_branch %> 分支
|
||||
</div>
|
||||
<% else %>
|
||||
<%= render "show_container" %>
|
||||
<div id="unmerged_tip">
|
||||
<%= render "show_container" %>
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
|
||||
|
|
|
@ -6,10 +6,10 @@
|
|||
<div class="alert alert-orange mb15 ">
|
||||
项目分支 <%= @request.source_branch %> 和 <%= @request.target_branch %> 似乎没有差异,请将新改动提交至源分支或者切换到其它目标分支
|
||||
</div>
|
||||
<%# elsif !@request.merge_when_build_succeeds %>
|
||||
<!--<div class="alert alert-orange mb15 ">-->
|
||||
<!--Pull Request中存在冲突,请先解决冲突或者手动进行合并。-->
|
||||
<!--</div>-->
|
||||
<% elsif @request.try(:merge_status) == "cannot_be_merged" %>
|
||||
<div class="alert alert-orange mb15 ">
|
||||
Pull Request中存在冲突,请先解决冲突或者手动进行合并。
|
||||
</div>
|
||||
<% else %>
|
||||
<% if is_project_manager?(User.current.id, @project.id) %>
|
||||
<div class="alert alert-orange mb15 ">
|
||||
|
|
|
@ -1,2 +1,4 @@
|
|||
$("#create_pull_request_error").html('<%= escape_javascript(render :partial => "pull_requests/error_message") %>');
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -511,3 +511,4 @@ zh:
|
|||
label_pull_request_conflic: 您创建的Pull Request尚未被管理员接受或者关闭,不能重新创建
|
||||
label_pull_request_forbidden: 您没有权限进行该操作
|
||||
label_pull_request_notfound: 您操作的页面不存在或者已被删除
|
||||
label_pull_request_datanotaccepted: Pull Request中存在冲突,请先解决冲突或者手动进行合并
|
|
@ -27,6 +27,9 @@ module Gitlab
|
|||
# Raised when API endpoint returns the HTTP status code 405.
|
||||
class MethodNotAllowed < Error; end
|
||||
|
||||
# Raised when API endpoint returns the HTTP status code 406.
|
||||
class DataNotAccepted < Error; end
|
||||
|
||||
# Raised when API endpoint returns the HTTP status code 409.
|
||||
class Conflict < Error; end
|
||||
|
||||
|
|
|
@ -68,6 +68,7 @@ module Gitlab
|
|||
when 403; raise Error::Forbidden.new error_message(response)
|
||||
when 404; raise Error::NotFound.new error_message(response)
|
||||
when 405; raise Error::MethodNotAllowed.new error_message(response)
|
||||
when 406; raise Error::DataNotAccepted.new error_message(response)
|
||||
when 409; raise Error::Conflict.new error_message(response)
|
||||
when 500; raise Error::InternalServerError.new error_message(response)
|
||||
when 502; raise Error::BadGateway.new error_message(response)
|
||||
|
|
Loading…
Reference in New Issue