summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorStan Hu <stanhu@gmail.com>2016-07-29 11:14:53 -0700
committerStan Hu <stanhu@gmail.com>2016-07-29 11:21:21 -0700
commit60529e021667194c402d4f6e85a83e02a8bb9f75 (patch)
treeae816493b2f43ec236f274e0edb9ddc46f0366d3 /app
parent6ad514d0663bad80e24586be0919a580cdaab8d2 (diff)
downloadgitlab-ce-60529e021667194c402d4f6e85a83e02a8bb9f75.tar.gz
Properly abort a merge when merge conflicts occurreject-merge-conflicts
If somehow a user attempted to accept a merge request that had conflicts (e.g. the "Accept Merge Request" button or the MR itself was not updated), `MergeService` did not properly detect that a conflict occurred. It would assume that the MR went through without any issues and close the MR as though everything was fine. This could cause data loss if the source branch were removed. Closes #20425
Diffstat (limited to 'app')
-rw-r--r--app/services/merge_requests/merge_service.rb8
1 files changed, 7 insertions, 1 deletions
diff --git a/app/services/merge_requests/merge_service.rb b/app/services/merge_requests/merge_service.rb
index 0dac0614141..b037780c431 100644
--- a/app/services/merge_requests/merge_service.rb
+++ b/app/services/merge_requests/merge_service.rb
@@ -35,7 +35,13 @@ module MergeRequests
}
commit_id = repository.merge(current_user, merge_request, options)
- merge_request.update(merge_commit_sha: commit_id)
+
+ if commit_id
+ merge_request.update(merge_commit_sha: commit_id)
+ else
+ merge_request.update(merge_error: 'Conflicts detected during merge')
+ false
+ end
rescue GitHooksService::PreReceiveError => e
merge_request.update(merge_error: e.message)
false