diff options
author | Sean McGivern <sean@gitlab.com> | 2016-06-01 10:21:22 +0100 |
---|---|---|
committer | Sean McGivern <sean@gitlab.com> | 2016-06-01 20:29:54 +0100 |
commit | d863d86aeb1993c2032da0610b3662e61960eb38 (patch) | |
tree | 4eb83c80e800467aecc7922a5ffd987313a1fcb0 /lib | |
parent | e9bb895b5ac639bcb4166b23b796566f0320741a (diff) | |
download | gitlab-ce-d863d86aeb1993c2032da0610b3662e61960eb38.tar.gz |
Add `sha` parameter to MR accept API
The `sha` parameter is optional, and when present, must match the
current HEAD SHA of the source branch. Otherwise, the API call fails
with a 409 Conflict and a message containing the current HEAD for the
source branch.
Also tidy up some doc wording.
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..50baf4c09ad 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.target_sha}", 409) + end + merge_params = { commit_message: params[:merge_commit_message], should_remove_source_branch: params[:should_remove_source_branch] |