2018-11-18 11:00:15 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2018-03-17 18:26:18 +05:30
|
|
|
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
|
2019-09-30 21:07:59 +05:30
|
|
|
if merge_request.gitaly_rebase_in_progress?
|
2018-03-17 18:26:18 +05:30
|
|
|
log_error('Rebase task canceled: Another rebase is already in progress', save_message_on_model: true)
|
|
|
|
return false
|
|
|
|
end
|
|
|
|
|
2019-07-31 22:56:46 +05:30
|
|
|
repository.rebase(current_user, merge_request)
|
2018-11-08 19:23:39 +05:30
|
|
|
|
2018-03-17 18:26:18 +05:30
|
|
|
true
|
|
|
|
rescue => e
|
|
|
|
log_error(REBASE_ERROR, save_message_on_model: true)
|
|
|
|
log_error(e.message)
|
|
|
|
false
|
2019-09-30 21:07:59 +05:30
|
|
|
ensure
|
|
|
|
merge_request.update_column(:rebase_jid, nil)
|
2018-03-17 18:26:18 +05:30
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|