2016-04-02 18:10:28 +05:30
|
|
|
module Commits
|
2016-06-02 11:05:42 +05:30
|
|
|
class RevertService < ChangeService
|
2016-04-02 18:10:28 +05:30
|
|
|
def commit
|
|
|
|
revert_into = @create_merge_request ? @commit.revert_branch_name : @target_branch
|
2016-06-02 11:05:42 +05:30
|
|
|
revert_tree_id = repository.check_revert_content(@commit, @target_branch)
|
2016-04-02 18:10:28 +05:30
|
|
|
|
2016-06-02 11:05:42 +05:30
|
|
|
if revert_tree_id
|
|
|
|
create_target_branch(revert_into) if @create_merge_request
|
2016-04-02 18:10:28 +05:30
|
|
|
|
2016-06-02 11:05:42 +05:30
|
|
|
repository.revert(current_user, @commit, revert_into, revert_tree_id)
|
|
|
|
success
|
|
|
|
else
|
|
|
|
error_msg = "Sorry, we cannot revert this #{@commit.change_type_title} automatically.
|
2016-04-02 18:10:28 +05:30
|
|
|
It may have already been reverted, or a more recent commit may have updated some of its content."
|
2016-06-02 11:05:42 +05:30
|
|
|
raise ChangeError, error_msg
|
2016-04-02 18:10:28 +05:30
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|