diff options
author | Douwe Maan <douwe@selenight.nl> | 2017-06-29 16:48:56 -0500 |
---|---|---|
committer | Douwe Maan <douwe@selenight.nl> | 2017-07-04 10:55:36 -0500 |
commit | 6489d1ad4ff40b6d5acf92280dde756d37bd2489 (patch) | |
tree | 881ff27eb82379d975190911f50c29595009fd8e /app | |
parent | 6205e45727db4d6720b7c3dc6ce010872b4f1628 (diff) | |
download | gitlab-ce-6489d1ad4ff40b6d5acf92280dde756d37bd2489.tar.gz |
Prevent accidental deletion of protected MR source branch by repeating checks before actual deletiondm-always-verify-source-branch-can-be-deleted
Diffstat (limited to 'app')
-rw-r--r-- | app/services/merge_requests/merge_service.rb | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/app/services/merge_requests/merge_service.rb b/app/services/merge_requests/merge_service.rb index b247cb89e5e..bc846e07f24 100644 --- a/app/services/merge_requests/merge_service.rb +++ b/app/services/merge_requests/merge_service.rb @@ -61,8 +61,12 @@ module MergeRequests MergeRequests::PostMergeService.new(project, current_user).execute(merge_request) if params[:should_remove_source_branch].present? || @merge_request.force_remove_source_branch? - DeleteBranchService.new(@merge_request.source_project, branch_deletion_user) - .execute(merge_request.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 end end |