diff options
author | Sean McGivern <sean@mcgivern.me.uk> | 2017-04-24 13:17:10 +0000 |
---|---|---|
committer | Sean McGivern <sean@mcgivern.me.uk> | 2017-04-24 13:17:10 +0000 |
commit | a77765e189a85e66524ce5f9320226e893bb360f (patch) | |
tree | 74453e6428dccb8babb2b3724de77176292e272e /lib | |
parent | 4740c994514b01eb4c610231872aa44fdd27cf63 (diff) | |
parent | e670cb271ed61cde68a932ce911553d7c8e4a6d5 (diff) | |
download | gitlab-ce-a77765e189a85e66524ce5f9320226e893bb360f.tar.gz |
Merge branch 'mrchrisw-22740-merge-api' into 'master'
Fix updating merge_when_build_succeeds via merge API endpoint
Closes #22740
See merge request !10873
Diffstat (limited to 'lib')
-rw-r--r-- | lib/api/merge_requests.rb | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/lib/api/merge_requests.rb b/lib/api/merge_requests.rb index cb7aec47cf0..c7dc2ea336f 100644 --- a/lib/api/merge_requests.rb +++ b/lib/api/merge_requests.rb @@ -197,14 +197,15 @@ module API end put ':id/merge_requests/:merge_request_iid/merge' do merge_request = find_project_merge_request(params[:merge_request_iid]) + merge_when_pipeline_succeeds = to_boolean(params[:merge_when_pipeline_succeeds]) # Merge request can not be merged # because user dont have permissions to push into target branch unauthorized! unless merge_request.can_be_merged_by?(current_user) - not_allowed! unless merge_request.mergeable_state? + not_allowed! unless merge_request.mergeable_state?(skip_ci_check: merge_when_pipeline_succeeds) - render_api_error!('Branch cannot be merged', 406) unless merge_request.mergeable? + render_api_error!('Branch cannot be merged', 406) unless merge_request.mergeable?(skip_ci_check: merge_when_pipeline_succeeds) if params[:sha] && merge_request.diff_head_sha != params[:sha] render_api_error!("SHA does not match HEAD of source branch: #{merge_request.diff_head_sha}", 409) @@ -215,7 +216,7 @@ module API should_remove_source_branch: params[:should_remove_source_branch] } - if params[:merge_when_pipeline_succeeds] && merge_request.head_pipeline && merge_request.head_pipeline.active? + if merge_when_pipeline_succeeds && merge_request.head_pipeline && merge_request.head_pipeline.active? ::MergeRequests::MergeWhenPipelineSucceedsService .new(merge_request.target_project, current_user, merge_params) .execute(merge_request) |