Commit 0b69b711 authored by Stan Hu's avatar Stan Hu

Make rebase from quick actions async

Also move rebase functionality into `MergeRequests::UpdateService` to
ensure merges/rebases are handled in the same location.
parent 69b88a0e
...@@ -127,14 +127,22 @@ module MergeRequests ...@@ -127,14 +127,22 @@ module MergeRequests
def handle_quick_actions(merge_request) def handle_quick_actions(merge_request)
super super
# Ignore /merge if /rebase is used to avoid an unexpected race # Ensure this parameter gets used as an attribute
params.delete(:merge) if params[:rebase] && params[:merge] rebase = params.delete(:rebase)
# Rebase is handled in MergeRequestActions to provide user feedback
params.delete(:rebase) if rebase
rebase_from_quick_action(merge_request)
# Ignore /merge if /rebase is used to avoid an unexpected race
params.delete(:merge)
end
merge_from_quick_action(merge_request) if params[:merge] merge_from_quick_action(merge_request) if params[:merge]
end end
def rebase_from_quick_action(merge_request)
merge_request.rebase_async(current_user.id)
end
def merge_from_quick_action(merge_request) def merge_from_quick_action(merge_request)
last_diff_sha = params.delete(:merge) last_diff_sha = params.delete(:merge)
......
...@@ -59,17 +59,9 @@ module Gitlab ...@@ -59,17 +59,9 @@ module Gitlab
# This will be used to avoid simultaneous /merge and /rebase actions # This will be used to avoid simultaneous /merge and /rebase actions
@updates[:rebase] = true @updates[:rebase] = true
result = MergeRequests::RebaseService.new(quick_action_target.project, current_user)
.execute(quick_action_target)
branch = quick_action_target.source_branch branch = quick_action_target.source_branch
@execution_message[:rebase] = @execution_message[:rebase] = _('Scheduled a rebase of branch %{branch}.') % { branch: branch }
if result[:status] == :success
_('Scheduled a rebase of branch %{branch}.')
else
_('Failed to schedule a rebase of %{branch}.')
end % { branch: branch }
end end
desc 'Toggle the Draft status' desc 'Toggle the Draft status'
......
...@@ -11880,9 +11880,6 @@ msgstr "" ...@@ -11880,9 +11880,6 @@ msgstr ""
msgid "Failed to save preferences." msgid "Failed to save preferences."
msgstr "" msgstr ""
msgid "Failed to schedule a rebase of %{branch}."
msgstr ""
msgid "Failed to set due date because the date format is invalid." msgid "Failed to set due date because the date format is invalid."
msgstr "" msgstr ""
......
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