Commit 52dd49ab authored by Sincheol (David) Kim's avatar Sincheol (David) Kim

Merge branch...

Merge branch '355567-bug-show-an-error-when-using-the-merge-quick-action-with-an-out-of-date-head-sha' into 'master'

Resolve "Bug: Show an error when using the /merge quick action with an out of date head sha"

See merge request gitlab-org/gitlab!82775
parents 0585c0b6 56a48bce
......@@ -25,6 +25,8 @@ module Gitlab
execution_message do
if params[:merge_request_diff_head_sha].blank?
_("Merge request diff sha parameter is required for the merge quick action.")
elsif params[:merge_request_diff_head_sha] != quick_action_target.diff_head_sha
_("Branch has been updated since the merge was requested.")
elsif preferred_strategy = preferred_auto_merge_strategy(quick_action_target)
_("Scheduled to merge this merge request (%{strategy}).") % { strategy: preferred_strategy.humanize }
else
......@@ -39,6 +41,8 @@ module Gitlab
command :merge do
next unless params[:merge_request_diff_head_sha].present?
next unless params[:merge_request_diff_head_sha] == quick_action_target.diff_head_sha
@updates[:merge] = params[:merge_request_diff_head_sha]
end
......
......@@ -5999,6 +5999,9 @@ msgstr ""
msgid "Branch changed"
msgstr ""
msgid "Branch has been updated since the merge was requested."
msgstr ""
msgid "Branch is already taken"
msgstr ""
......
......@@ -759,6 +759,7 @@ RSpec.describe QuickActions::InterpretService do
context 'merge command' do
let(:service) { described_class.new(project, developer, { merge_request_diff_head_sha: merge_request.diff_head_sha }) }
let(:merge_request) { create(:merge_request, source_project: repository_project) }
it_behaves_like 'merge immediately command' do
let(:content) { '/merge' }
......@@ -789,7 +790,7 @@ RSpec.describe QuickActions::InterpretService do
context 'can not be merged when sha does not match' do
let(:service) { described_class.new(project, developer, { merge_request_diff_head_sha: 'othersha' }) }
it_behaves_like 'failed command', 'Could not apply merge command.' do
it_behaves_like 'failed command', 'Branch has been updated since the merge was requested.' do
let(:content) { "/merge" }
let(:issuable) { merge_request }
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