Commit 836a562a authored by Stan Hu's avatar Stan Hu

Prevent rebase from being run in quick action when there are conflicts

When there are merge conflicts, a rebase will always fail. Since the
`cannot_be_merged` state is cached, we can use that to tell the user
that the rebase will not go through until the conflicts are resolved.
parent aaeddaa7
---
title: Prevent rebase from being run in quick action when there are conflicts
merge_request: 51243
author:
type: fixed
......@@ -57,6 +57,11 @@ module Gitlab
access_check.can_push_to_branch?(merge_request.source_branch)
end
command :rebase do
if quick_action_target.cannot_be_merged?
@execution_message[:rebase] = _('This merge request cannot be rebased while there are conflicts.')
next
end
if quick_action_target.rebase_in_progress?
@execution_message[:rebase] = _('A rebase is already in progress.')
next
......
......@@ -28776,6 +28776,9 @@ msgstr ""
msgid "This means you can not push code until you create an empty repository or import existing one."
msgstr ""
msgid "This merge request cannot be rebased while there are conflicts."
msgstr ""
msgid "This merge request does not have accessibility reports"
msgstr ""
......
......@@ -63,6 +63,16 @@ RSpec.shared_examples 'rebase quick action' do
expect(page).not_to have_content 'Scheduled a rebase'
end
end
context 'when there are conflicts in the merge request' do
let!(:merge_request) { create(:merge_request, source_project: project, target_project: project, source_branch: 'conflict-missing-side', target_branch: 'conflict-start', merge_status: :cannot_be_merged) }
it 'does not rebase the MR' do
add_note("/rebase")
expect(page).to have_content 'This merge request cannot be rebased while there are conflicts.'
end
end
end
context 'when the current user cannot rebase the MR' 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