diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-07-20 15:26:25 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-07-20 15:26:25 +0300 |
commit | a09983ae35713f5a2bbb100981116d31ce99826e (patch) | |
tree | 2ee2af7bd104d57086db360a7e6d8c9d5d43667a /app/services/merge_requests/update_service.rb | |
parent | 18c5ab32b738c0b6ecb4d0df3994000482f34bd8 (diff) |
Add latest changes from gitlab-org/gitlab@13-2-stable-ee
Diffstat (limited to 'app/services/merge_requests/update_service.rb')
-rw-r--r-- | app/services/merge_requests/update_service.rb | 56 |
1 files changed, 33 insertions, 23 deletions
diff --git a/app/services/merge_requests/update_service.rb b/app/services/merge_requests/update_service.rb index 561695baeab..29e0c22b155 100644 --- a/app/services/merge_requests/update_service.rb +++ b/app/services/merge_requests/update_service.rb @@ -2,6 +2,8 @@ module MergeRequests class UpdateService < MergeRequests::BaseService + extend ::Gitlab::Utils::Override + def execute(merge_request) # We don't allow change of source/target projects and source branch # after merge request was created @@ -9,14 +11,11 @@ module MergeRequests params.delete(:target_project_id) params.delete(:source_branch) - merge_from_quick_action(merge_request) if params[:merge] - if merge_request.closed_without_fork? params.delete(:target_branch) params.delete(:force_remove_source_branch) end - handle_wip_event(merge_request) update_task_event(merge_request) || update(merge_request) end @@ -77,26 +76,6 @@ module MergeRequests todo_service.update_merge_request(merge_request, current_user) end - def merge_from_quick_action(merge_request) - last_diff_sha = params.delete(:merge) - - if Feature.enabled?(:merge_orchestration_service, merge_request.project, default_enabled: true) - MergeRequests::MergeOrchestrationService - .new(project, current_user, { sha: last_diff_sha }) - .execute(merge_request) - else - return unless merge_request.mergeable_with_quick_action?(current_user, last_diff_sha: last_diff_sha) - - merge_request.update(merge_error: nil) - - if merge_request.head_pipeline_active? - AutoMergeService.new(project, current_user, { sha: last_diff_sha }).execute(merge_request, AutoMergeService::STRATEGY_MERGE_WHEN_PIPELINE_SUCCEEDS) - else - merge_request.merge_async(current_user.id, { sha: last_diff_sha }) - end - end - end - def reopen_service MergeRequests::ReopenService end @@ -134,6 +113,37 @@ module MergeRequests issuable, issuable.project, current_user, branch_type, old_branch, new_branch) end + + override :handle_quick_actions + def handle_quick_actions(merge_request) + super + merge_from_quick_action(merge_request) if params[:merge] + end + + def merge_from_quick_action(merge_request) + last_diff_sha = params.delete(:merge) + + if Feature.enabled?(:merge_orchestration_service, merge_request.project, default_enabled: true) + MergeRequests::MergeOrchestrationService + .new(project, current_user, { sha: last_diff_sha }) + .execute(merge_request) + else + return unless merge_request.mergeable_with_quick_action?(current_user, last_diff_sha: last_diff_sha) + + merge_request.update(merge_error: nil) + + if merge_request.head_pipeline_active? + AutoMergeService.new(project, current_user, { sha: last_diff_sha }).execute(merge_request, AutoMergeService::STRATEGY_MERGE_WHEN_PIPELINE_SUCCEEDS) + else + merge_request.merge_async(current_user.id, { sha: last_diff_sha }) + end + end + end + + override :quick_action_options + def quick_action_options + { merge_request_diff_head_sha: params.delete(:merge_request_diff_head_sha) } + end end end |