gitlab-org--gitlab-foss/app/services/merge_requests/rebase_service.rb
Jan Provaznik a560f785f7 Store only generic message if rebase fails
Instead of storing detailed rebase error, only a generic message is
stored with MR. The reason is that this message is exposed and displayed
to end user and there is no reason to expose detailed backend
information. Error message is still logged so detailed information
can be found in logfile by admin if needed.

Related #41820
2018-01-09 17:04:28 +01:00

32 lines
788 B
Ruby

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
rebase_sha = repository.rebase(current_user, merge_request)
merge_request.update_attributes(rebase_commit_sha: rebase_sha)
true
rescue => e
log_error(REBASE_ERROR, save_message_on_model: true)
log_error(e.message)
false
end
end
end