diff options
author | Kerri Miller <kerrizor@kerrizor.com> | 2019-05-07 16:06:53 +0000 |
---|---|---|
committer | James Lopez <james@gitlab.com> | 2019-05-07 16:06:53 +0000 |
commit | 29f9d92642539eaa04bdb485425d6f1cd3b459fd (patch) | |
tree | c23954af03947e8af936e2c6428340c28dbf3aab /lib | |
parent | f0ff33d8bf3c0fd2dae4f6c762f161b127aa88d7 (diff) | |
download | gitlab-ce-29f9d92642539eaa04bdb485425d6f1cd3b459fd.tar.gz |
Confirm existence of head_pipeline if pipeline success required
Pipelines are created by an async worker, so a rapid sequence of API
calls can trigger a state where the pipeline, whose existence is part of
determining if we wait for the pipeline to successfully complete before
merging, can trigger the MR to be immediately merged instead.
Closes https://gitlab.com/gitlab-org/gitlab-ce/issues/55127
Diffstat (limited to 'lib')
-rw-r--r-- | lib/api/merge_requests.rb | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/lib/api/merge_requests.rb b/lib/api/merge_requests.rb index ce85772e4ed..daa98c22e5e 100644 --- a/lib/api/merge_requests.rb +++ b/lib/api/merge_requests.rb @@ -367,6 +367,10 @@ module API merge_request = find_project_merge_request(params[:merge_request_iid]) merge_when_pipeline_succeeds = to_boolean(params[:merge_when_pipeline_succeeds]) + if merge_when_pipeline_succeeds || merge_request.merge_when_pipeline_succeeds + render_api_error!('Not allowed: pipeline does not exist', 405) unless merge_request.head_pipeline + end + # 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) |