Commit 5ac8a536 authored by Kerri Miller's avatar Kerri Miller

Merge branch 'sh-rebase-quick-action-feedback' into 'master'

Avoid 409 StaleObjectError errors with /rebase

See merge request gitlab-org/gitlab!50719
parents d4cda0bf 53c9af39
---
title: Avoid 409 StaleObjectError errors with /rebase
merge_request: 50719
author:
type: fixed
......@@ -48,6 +48,7 @@ module Gitlab
condition do
merge_request = quick_action_target
next false unless merge_request.open?
next false unless merge_request.source_branch_exists?
access_check = ::Gitlab::UserAccess
......@@ -56,6 +57,11 @@ module Gitlab
access_check.can_push_to_branch?(merge_request.source_branch)
end
command :rebase do
if quick_action_target.rebase_in_progress?
@execution_message[:rebase] = _('A rebase is already in progress.')
next
end
# This will be used to avoid simultaneous "/merge" and "/rebase" actions
@updates[:rebase] = true
......
......@@ -1325,6 +1325,9 @@ msgstr ""
msgid "A ready-to-go template for use with iOS Swift apps"
msgstr ""
msgid "A rebase is already in progress."
msgstr ""
msgid "A regular expression that will be used to find the test coverage output in the job log. Leave blank to disable"
msgstr ""
......
......@@ -36,6 +36,33 @@ RSpec.shared_examples 'rebase quick action' do
expect(page).to have_content "Scheduled a rebase of branch #{merge_request.source_branch}."
end
context 'when the merge request is closed' do
before do
merge_request.close!
end
it 'does not rebase the MR', :sidekiq_inline do
add_note("/rebase")
expect(page).not_to have_content 'Scheduled a rebase'
end
end
context 'when a rebase is in progress', :sidekiq_inline, :clean_gitlab_redis_shared_state do
before do
jid = SecureRandom.hex
merge_request.update!(rebase_jid: jid)
Gitlab::SidekiqStatus.set(jid)
end
it 'tells the user a rebase is in progress' do
add_note('/rebase')
expect(page).to have_content 'A rebase is already in progress.'
expect(page).not_to have_content 'Scheduled a rebase'
end
end
end
context 'when the current user cannot rebase the MR' do
......@@ -48,7 +75,7 @@ RSpec.shared_examples 'rebase quick action' do
it 'does not rebase the MR' do
add_note("/rebase")
expect(page).not_to have_content 'Your commands have been executed!'
expect(page).not_to have_content 'Scheduled a rebase'
end
end
end
......
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