Commit 69b88a0e authored by Stan Hu's avatar Stan Hu

Prevent simultaneous use of /rebase and /merge actions

Since /rebase and /merge actions are not atomic, we may run into
confusing race conditions if these are applied together. For now, we
just ignore the /merge and proceed with the rebase.
parent 6700f226
......@@ -126,6 +126,12 @@ module MergeRequests
override :handle_quick_actions
def handle_quick_actions(merge_request)
super
# Ignore /merge if /rebase is used to avoid an unexpected race
params.delete(:merge) if params[:rebase] && params[:merge]
# Rebase is handled in MergeRequestActions to provide user feedback
params.delete(:rebase)
merge_from_quick_action(merge_request) if params[:merge]
end
......
......@@ -56,6 +56,9 @@ module Gitlab
access_check.can_push_to_branch?(merge_request.source_branch)
end
command :rebase do
# This will be used to avoid simultaneous /merge and /rebase actions
@updates[:rebase] = true
result = MergeRequests::RebaseService.new(quick_action_target.project, current_user)
.execute(quick_action_target)
......
......@@ -14,6 +14,14 @@ RSpec.shared_examples 'rebase quick action' do
expect(page).not_to have_content('commit behind the target branch')
expect(merge_request.reload).not_to be_merged
end
it 'ignores /merge if /rebase is specified', :sidekiq_inline do
fill_in('Description', with: "/merge\n/rebase")
click_button('Save changes')
expect(page).not_to have_content('commit behind the target branch')
expect(merge_request.reload).not_to be_merged
end
end
context 'when creating a new note' do
......
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