diff options
author | Douwe Maan <douwe@gitlab.com> | 2016-06-03 12:41:58 +0000 |
---|---|---|
committer | Douwe Maan <douwe@gitlab.com> | 2016-06-03 12:41:58 +0000 |
commit | 0e2490c0cb9fca00baac08ae6b1280f62fa7d336 (patch) | |
tree | 8511fe1766c450b0a684a3c7d5b0535e85917862 /lib | |
parent | 4c8d4c620c1e6af89de2a6e7407ac078744a0dcd (diff) | |
parent | 4f726683cb59da54f47302880d5c0c447638402a (diff) | |
download | gitlab-ce-0e2490c0cb9fca00baac08ae6b1280f62fa7d336.tar.gz |
Merge branch '14139-sha-parameter-in-accept-merge-request-api' into 'master'
Resolve "SHA parameter in accept merge request API"
Add a `sha` parameter to the MR merge API, which must match the source SHA for the branch to be merged.
Also add the same parameter to the UI:
![MR_SHA](/uploads/616da728695dc19fa7ef7ef6a016ff81/MR_SHA.gif)
@DouweM and I discussed adding some smart feature to that, like updating the source SHA on navigating to the diff tab, but for now it will just require a refresh :smiley:
Closes #14139.
See merge request !4414
Diffstat (limited to 'lib')
-rw-r--r-- | lib/api/merge_requests.rb | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/lib/api/merge_requests.rb b/lib/api/merge_requests.rb index 4e7de8867b4..db304abe1c3 100644 --- a/lib/api/merge_requests.rb +++ b/lib/api/merge_requests.rb @@ -218,6 +218,7 @@ module API # merge_commit_message (optional) - Custom merge commit message # should_remove_source_branch (optional) - When true, the source branch will be deleted if possible # merge_when_build_succeeds (optional) - When true, this MR will be merged when the build succeeds + # sha (optional) - When present, must have the HEAD SHA of the source branch # Example: # PUT /projects/:id/merge_requests/:merge_request_id/merge # @@ -233,6 +234,10 @@ module API render_api_error!('Branch cannot be merged', 406) unless merge_request.can_be_merged? + if params[:sha] && merge_request.source_sha != params[:sha] + render_api_error!("SHA does not match HEAD of source branch: #{merge_request.source_sha}", 409) + end + merge_params = { commit_message: params[:merge_commit_message], should_remove_source_branch: params[:should_remove_source_branch] |