summaryrefslogtreecommitdiff
path: root/lib/gitlab/git/patches/commit_patches.rb
blob: c62994432d36fdb1a8b570ffd0ab6346f9c75902 (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
# frozen_string_literal: true

module Gitlab
  module Git
    module Patches
      class CommitPatches
        include Gitlab::Git::WrapsGitalyErrors

        def initialize(user, repository, branch, patch_collection)
          @user, @repository, @branch, @patches = user, repository, branch, patch_collection
        end

        def commit
          repository.with_cache_hooks do
            wrapped_gitaly_errors do
              operation_service.user_commit_patches(user, branch, patches.content)
            end
          end
        end

        private

        attr_reader :user, :repository, :branch, :patches

        def operation_service
          repository.raw.gitaly_operation_client
        end
      end
    end
  end
end