|
|
|
@ -2,7 +2,7 @@ class PullRequestsController < ApplicationController
|
|
|
|
|
before_action :require_login
|
|
|
|
|
before_action :find_project
|
|
|
|
|
before_action :set_repository
|
|
|
|
|
before_action :find_pull_request, except: [:index, :new, :create]
|
|
|
|
|
before_action :find_pull_request, except: [:index, :new, :create, :check_can_merge]
|
|
|
|
|
include TagChosenHelper
|
|
|
|
|
include ApplicationHelper
|
|
|
|
|
|
|
|
|
@ -96,8 +96,8 @@ class PullRequestsController < ApplicationController
|
|
|
|
|
project_id: @project.id,
|
|
|
|
|
subject: params[:title],
|
|
|
|
|
description: params[:body],
|
|
|
|
|
assigned_to_id: params[:assigned_to_id].to_s,
|
|
|
|
|
fixed_version_id: params[:fixed_version_id].to_i,
|
|
|
|
|
assigned_to_id: params[:assigned_to_id],
|
|
|
|
|
fixed_version_id: params[:fixed_version_id],
|
|
|
|
|
issue_tags_value: params[:issue_tag_ids].present? ? params[:issue_tag_ids].join(",") : "",
|
|
|
|
|
issue_classify: "pull_request",
|
|
|
|
|
issue_type: params[:issue_type] || "1",
|
|
|
|
@ -278,7 +278,9 @@ class PullRequestsController < ApplicationController
|
|
|
|
|
}
|
|
|
|
|
merge_pr = Gitea::PullRequest::MergeService.new(current_user, @repository.try(:identifier), @pull_request.try(:gpid), requests_params).call
|
|
|
|
|
if @pull_request.update_attribute(:status, 1) && merge_pr
|
|
|
|
|
@pull_request.project_trends.create(user_id: current_user.id, project_id: @project.id, action_type: "merge")
|
|
|
|
|
# @pull_request.project_trends.create(user_id: current_user.id, project_id: @project.id, action_type: "merge")
|
|
|
|
|
@pull_request&.project_trends&.update_all(action_type: "close")
|
|
|
|
|
|
|
|
|
|
@issue.custom_journal_detail("merge", "", "该合并请求已被合并")
|
|
|
|
|
normal_status(1, "合并成功")
|
|
|
|
|
else
|
|
|
|
@ -343,7 +345,26 @@ class PullRequestsController < ApplicationController
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def check_can_merge
|
|
|
|
|
target_head = params[:head] #源分支
|
|
|
|
|
target_base = params[:base] #目标分支
|
|
|
|
|
if target_head.blank? || target_base.blank?
|
|
|
|
|
normal_status(-1, "请选择分支。")
|
|
|
|
|
elsif target_head === target_base
|
|
|
|
|
normal_status(-1, "分支内容相同,无需创建合并请求。")
|
|
|
|
|
else
|
|
|
|
|
can_merge = @project&.pull_requests.where(user_id: current_user&.id, head: target_head, base: target_base, status: 0)
|
|
|
|
|
if can_merge.present?
|
|
|
|
|
render json: {
|
|
|
|
|
status: -2,
|
|
|
|
|
message: "在这些分支之间的合并请求已存在",
|
|
|
|
|
pull_request_id: can_merge.first.id
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
normal_status(0, "可以合并")
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private
|
|
|
|
|