summaryrefslogtreecommitdiff
path: root/app/services/files/multi_service.rb
blob: bfacc4628472ad8032df7fe5501339fb5b519bab (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
module Files
  class MultiService < Files::BaseService
    def create_commit!
      repository.multi_action(
        user: current_user,
        message: @commit_message,
        branch_name: @branch_name,
        actions: params[:actions],
        author_email: @author_email,
        author_name: @author_name,
        start_project: @start_project,
        start_branch_name: @start_branch
      )
    end

    private

    def validate!
      super

      params[:actions].each do |action|
        validate_action!(action)
      end
    end

    def validate_action!(action)
      unless Gitlab::Git::Index::ACTIONS.include?(action[:action].to_s)
        raise_error("Unknown action '#{action[:action]}'")
      end
    end
  end
end