Read about our upcoming Code of Conduct on this issue

This instance was upgraded to Heptapod 0.28.0 today

change_service.rb 1.01 KB
Newer Older
1
2
# frozen_string_literal: true

3
module Commits
Douwe Maan's avatar
Douwe Maan committed
4
5
6
  class ChangeService < Commits::CreateService
    def initialize(*args)
      super
7
8
9
10

      @commit = params[:commit]
    end

11
12
13
14
15
    private

    def commit_change(action)
      raise NotImplementedError unless repository.respond_to?(action)

16
17
      # rubocop:disable GitlabSecurity/PublicSend
      message = @commit.public_send(:"#{action}_message", current_user)
18
19
20
21
      repository.public_send(
        action,
        current_user,
        @commit,
Douwe Maan's avatar
Douwe Maan committed
22
        @branch_name,
23
        message,
24
25
        start_project: @start_project,
        start_branch_name: @start_branch)
26
    rescue Gitlab::Git::Repository::CreateTreeError => ex
27
28
29
30
31
32
      act = action.to_s.dasherize
      type = @commit.change_type_title(current_user)

      error_msg = "Sorry, we cannot #{act} this #{type} automatically. " \
        "This #{type} may already have been #{act}ed, or a more recent " \
        "commit may have updated some of its content."
33
34

      raise ChangeError.new(error_msg, ex.error_code)
35
    end
36
37
  end
end