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

33 lines
1,023 B
Ruby
Raw Normal View History

2018-11-18 11:00:15 +05:30
# frozen_string_literal: true
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)
2018-03-17 18:26:18 +05:30
# rubocop:disable GitlabSecurity/PublicSend
message = @commit.public_send(:"#{action}_message", current_user)
2017-08-17 22:00:37 +05:30
repository.public_send(
action,
current_user,
@commit,
@branch_name,
2018-03-17 18:26:18 +05:30
message,
2017-08-17 22:00:37 +05:30
start_project: @start_project,
start_branch_name: @start_branch)
2018-03-17 18:26:18 +05:30
rescue Gitlab::Git::Repository::CreateTreeError
2017-08-17 22:00:37 +05:30
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