fixed:同一方向pullrequest不允许存在

This commit is contained in:
yystopf 2025-06-25 16:03:31 +08:00
parent 6bcdc20500
commit bb720d20c1
1 changed files with 12 additions and 4 deletions

View File

@ -14,11 +14,19 @@ class Api::V1::Projects::Pulls::PullsController < Api::V1::BaseController
end
def reopen
@result_object = Api::V1::Projects::Pulls::ReopenService.call(@project, @pull_request, current_user)
if @result_object
render_ok
can_merge = @project&.pull_requests.where(head: @pull_request.head, base: @pull_request.base, status: 0, is_original: @pull_request.is_original, fork_project_id: @pull_request.fork_project_id)
if can_merge.present?
render json: {
status: -2,
message: "在这些分支之间的合并请求已存在:<a href='/#{@project.owner.login}/#{@project.identifier}/pulls/#{can_merge.first.id}''>#{can_merge.first.try(:title)}</a>",
}
else
render_error("合并请求重新打开失败!")
@result_object = Api::V1::Projects::Pulls::ReopenService.call(@project, @pull_request, current_user)
if @result_object
render_ok
else
render_error("合并请求重新打开失败!")
end
end
end