49cb4b3dfc
The new two-step Gitaly `Rebase` RPC yields the rebase commit SHA to the client before proceeding with the rebase. This avoids an issue where the rebase commit SHA was returned when the RPC had fully completed, and in some cases this would be after the Rails `post_receive` worker services had already run. In these situations, the merge request did not yet have its rebase_commit_sha attribute set introducing the possibility for bugs (such as previous approvals being reset). https://gitlab.com/gitlab-org/gitlab-ee/issues/5966
32 lines
736 B
Ruby
32 lines
736 B
Ruby
# frozen_string_literal: true
|
|
|
|
module MergeRequests
|
|
class RebaseService < MergeRequests::WorkingCopyBaseService
|
|
REBASE_ERROR = 'Rebase failed. Please rebase locally'.freeze
|
|
|
|
def execute(merge_request)
|
|
@merge_request = merge_request
|
|
|
|
if rebase
|
|
success
|
|
else
|
|
error(REBASE_ERROR)
|
|
end
|
|
end
|
|
|
|
def rebase
|
|
if merge_request.rebase_in_progress?
|
|
log_error('Rebase task canceled: Another rebase is already in progress', save_message_on_model: true)
|
|
return false
|
|
end
|
|
|
|
repository.rebase(current_user, merge_request)
|
|
|
|
true
|
|
rescue => e
|
|
log_error(REBASE_ERROR, save_message_on_model: true)
|
|
log_error(e.message)
|
|
false
|
|
end
|
|
end
|
|
end
|