2016-04-18 07:39:07 +00:00
module Commits
2017-04-20 00:37:44 +00:00
class ChangeService < Commits :: CreateService
def initialize ( * args )
super
2016-04-18 07:39:07 +00:00
@commit = params [ :commit ]
end
2016-09-15 14:30:27 +00:00
private
def commit_change ( action )
raise NotImplementedError unless repository . respond_to? ( action )
2017-02-17 00:24:56 +00:00
repository . public_send (
action ,
current_user ,
@commit ,
2017-04-20 00:37:44 +00:00
@branch_name ,
2017-02-17 00:24:56 +00:00
start_project : @start_project ,
start_branch_name : @start_branch )
2017-03-03 13:23:49 +00:00
rescue Repository :: CreateTreeError
2017-03-03 00:11:23 +00:00
error_msg = " Sorry, we cannot #{ action . to_s . dasherize } this #{ @commit . change_type_title ( current_user ) } automatically.
2017-04-20 00:37:44 +00:00
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."
2017-03-03 00:11:23 +00:00
raise ChangeError , error_msg
2016-09-15 14:30:27 +00:00
end
2016-04-18 07:39:07 +00:00
end
end