debian-mirror-gitlab/app/services/commits/change_service.rb

28 lines
840 B
Ruby
Raw Normal View History

2016-06-02 11:05:42 +05:30
module Commits
2017-08-17 22:00:37 +05:30
class ChangeService < Commits::CreateService
def initialize(*args)
super
2016-06-02 11:05:42 +05:30
@commit = params[:commit]
end
2016-09-29 09:46:39 +05:30
private
def commit_change(action)
raise NotImplementedError unless repository.respond_to?(action)
2017-08-17 22:00:37 +05:30
repository.public_send(
action,
current_user,
@commit,
@branch_name,
start_project: @start_project,
start_branch_name: @start_branch)
rescue Repository::CreateTreeError
error_msg = "Sorry, we cannot #{action.to_s.dasherize} this #{@commit.change_type_title(current_user)} automatically.
This #{@commit.change_type_title(current_user)} may already have been #{action.to_s.dasherize}ed, or a more recent commit may have updated some of its content."
raise ChangeError, error_msg
2016-06-02 11:05:42 +05:30
end
end
end