diff options
author | micael.bergeron <micaelbergeron@gmail.com> | 2017-10-11 16:29:37 -0400 |
---|---|---|
committer | micael.bergeron <micaelbergeron@gmail.com> | 2017-10-11 16:41:41 -0400 |
commit | 6eeff4cdf64cb2d305f6babd70bfcba8a3c7a14e (patch) | |
tree | d97cf7a3111bb237a507c2ce3f28a455fdd4b30d /app | |
parent | 845b2f1abe408da48441d1fd271705684f15b114 (diff) | |
download | gitlab-ce-6eeff4cdf64cb2d305f6babd70bfcba8a3c7a14e.tar.gz |
fix the merger override to remove source branch
Diffstat (limited to 'app')
-rw-r--r-- | app/services/merge_requests/merge_service.rb | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/app/services/merge_requests/merge_service.rb b/app/services/merge_requests/merge_service.rb index a110abf8256..89003d78c9f 100644 --- a/app/services/merge_requests/merge_service.rb +++ b/app/services/merge_requests/merge_service.rb @@ -60,13 +60,11 @@ module MergeRequests def after_merge MergeRequests::PostMergeService.new(project, current_user).execute(merge_request) - if params[:should_remove_source_branch].present? || @merge_request.force_remove_source_branch? + if delete_source_branch? # Verify again that the source branch can be removed, since branch may be protected, # or the source branch may have been updated. - if @merge_request.can_remove_source_branch?(branch_deletion_user) - DeleteBranchService.new(@merge_request.source_project, branch_deletion_user) - .execute(merge_request.source_branch) - end + DeleteBranchService.new(@merge_request.source_project, branch_deletion_user) + .execute(merge_request.source_branch) end end @@ -78,6 +76,11 @@ module MergeRequests @merge_request.force_remove_source_branch? ? @merge_request.author : current_user end + def delete_source_branch? + params.fetch('should_remove_source_branch', @merge_request.force_remove_source_branch?) && + @merge_request.can_remove_source_branch?(branch_deletion_user) + end + # Logs merge error message and cleans `MergeRequest#merge_jid`. # def handle_merge_error(log_message:, save_message_on_model: false) |