Commit 8eb23838 authored by Marc Shaw's avatar Marc Shaw

Return error msg when using merge quick action without required params

Issue: gitlab.com/gitlab-org/gitlab/-/issues/354093
MR: gitlab.com/gitlab-org/gitlab/-/merge_requests/82278
parent a3a63d3f
......@@ -23,7 +23,9 @@ module Gitlab
end
end
execution_message do
if preferred_strategy = preferred_auto_merge_strategy(quick_action_target)
if params[:merge_request_diff_head_sha].blank?
_("Merge request diff sha parameter is required for the merge quick action.")
elsif preferred_strategy = preferred_auto_merge_strategy(quick_action_target)
_("Scheduled to merge this merge request (%{strategy}).") % { strategy: preferred_strategy.humanize }
else
_('Merged this merge request.')
......@@ -35,6 +37,8 @@ module Gitlab
merge_orchestration_service.can_merge?(quick_action_target)
end
command :merge do
next unless params[:merge_request_diff_head_sha].present?
@updates[:merge] = params[:merge_request_diff_head_sha]
end
......
......@@ -23020,6 +23020,9 @@ msgstr ""
msgid "Merge request dependencies"
msgstr ""
msgid "Merge request diff sha parameter is required for the merge quick action."
msgstr ""
msgid "Merge request events"
msgstr ""
......
......@@ -799,10 +799,9 @@ RSpec.describe QuickActions::InterpretService do
let(:project) { repository_project }
let(:service) { described_class.new(project, developer, {}) }
it 'precheck passes and returns merge command' do
_, updates, _ = service.execute('/merge', merge_request)
expect(updates).to eq(merge: nil)
it_behaves_like 'failed command', 'Merge request diff sha parameter is required for the merge quick action.' do
let(:content) { "/merge" }
let(:issuable) { merge_request }
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