Commit 0ea0b557 authored by Mayra Cabrera's avatar Mayra Cabrera

Merge branch...

Merge branch '354093-return-appropriate-error-when-merge_request_diff_head_sha-is-not-given' into 'master'

Resolve "Return appropriate error when merge_request_diff_head_sha is not given"

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