fixed 分支删除时有开启的pr需要一同关闭

This commit is contained in:
xxq250 2023-08-30 13:51:56 +08:00
parent a2fb12ffd6
commit 810e8b9887
1 changed files with 8 additions and 1 deletions

View File

@ -17,7 +17,14 @@ class Api::V1::Projects::BranchesController < Api::V1::BaseController
def destroy
@result_object = Api::V1::Projects::Branches::DeleteService.call(@project, params[:name], current_user&.gitea_token)
if @result_object
if @result_object
# 有开启的pr需要一同关闭
open_pull_requests = @project.pull_requests.opening.where(head: params[:name]).where(user_id: current_user.id)
if open_pull_requests.present?
open_pull_requests.each do |pull_request|
PullRequests::CloseService.call(@project.owner, @project.repository, pull_request, current_user)
end
end
return render_ok
else
return render_error('删除分支失败!')