Commit 2cfbf3e8 authored by Robert Speicher's avatar Robert Speicher

Merge branch...

Merge branch '18131-pressing-merge-when-build-succeeds-at-the-same-exact-time-that-a-build-is-failing-will-merge-the-failed-build' into 'master'

Fix race condition on auto merge

Resolves #18131

See merge request !4443
parents 32a5ff70 17ad286e
...@@ -42,6 +42,7 @@ v 8.9.0 (unreleased) ...@@ -42,6 +42,7 @@ v 8.9.0 (unreleased)
- Add DB index on users.state - Add DB index on users.state
- Add rake task 'gitlab:db:configure' for conditionally seeding or migrating the database - Add rake task 'gitlab:db:configure' for conditionally seeding or migrating the database
- Changed the Slack build message to use the singular duration if necessary (Aran Koning) - Changed the Slack build message to use the singular duration if necessary (Aran Koning)
- Fix race condition on merge when build succeeds
- Links from a wiki page to other wiki pages should be rewritten as expected - Links from a wiki page to other wiki pages should be rewritten as expected
- Add option to project to only allow merge requests to be merged if the build succeeds (Rui Santos) - Add option to project to only allow merge requests to be merged if the build succeeds (Rui Santos)
- Fix issues filter when ordering by milestone - Fix issues filter when ordering by milestone
......
...@@ -204,10 +204,19 @@ class Projects::MergeRequestsController < Projects::ApplicationController ...@@ -204,10 +204,19 @@ class Projects::MergeRequestsController < Projects::ApplicationController
@merge_request.update(merge_error: nil) @merge_request.update(merge_error: nil)
if params[:merge_when_build_succeeds].present? && @merge_request.pipeline && @merge_request.pipeline.active? if params[:merge_when_build_succeeds].present?
MergeRequests::MergeWhenBuildSucceedsService.new(@project, current_user, merge_params) if @merge_request.pipeline && @merge_request.pipeline.active?
.execute(@merge_request) MergeRequests::MergeWhenBuildSucceedsService.new(@project, current_user, merge_params)
@status = :merge_when_build_succeeds .execute(@merge_request)
@status = :merge_when_build_succeeds
elsif @merge_request.pipeline.success?
# This can be triggered when a user clicks the auto merge button while
# the tests finish at about the same time
MergeWorker.perform_async(@merge_request.id, current_user.id, params)
@status = :success
else
@status = :failed
end
else else
MergeWorker.perform_async(@merge_request.id, current_user.id, params) MergeWorker.perform_async(@merge_request.id, current_user.id, params)
@status = :success @status = :success
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment