diff options
author | Sean McGivern <sean@mcgivern.me.uk> | 2017-10-12 18:08:06 +0300 |
---|---|---|
committer | Sean McGivern <sean@mcgivern.me.uk> | 2017-10-12 18:08:06 +0300 |
commit | af3c98bb93ede723f305477122bfdce927066307 (patch) | |
tree | 4d87b932064019616561aa288fe282feb33e94c9 /app/services | |
parent | f160b2dbe378c7932c11ab56984003a29fb01f42 (diff) | |
parent | d1acadceb1216fbfb0a9783a6dc7fa72d849846f (diff) |
Merge branch '34897-delete-branch-after-merge' into 'master'
Resolve "remove source branch" checkbox from merge widget being ignored
Closes #34897
See merge request gitlab-org/gitlab-ce!14832
Diffstat (limited to 'app/services')
-rw-r--r-- | app/services/merge_requests/merge_service.rb | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/app/services/merge_requests/merge_service.rb b/app/services/merge_requests/merge_service.rb index a110abf8256..8c5821aa870 100644 --- a/app/services/merge_requests/merge_service.rb +++ b/app/services/merge_requests/merge_service.rb @@ -60,13 +60,9 @@ 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? - # 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 + if delete_source_branch? + DeleteBranchService.new(@merge_request.source_project, branch_deletion_user) + .execute(merge_request.source_branch) end end @@ -78,6 +74,14 @@ module MergeRequests @merge_request.force_remove_source_branch? ? @merge_request.author : current_user end + # Verify again that the source branch can be removed, since branch may be protected, + # or the source branch may have been updated, or the user may not have permission + # + 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) |