6fbdc5ed52
This allows users to add patches as attachments to merge request created via email. When an email to create a merge request is sent, all the attachments ending in `.patch` will be applied to the branch specified in the subject of the email. If the branch did not exist, it will be created from the HEAD of the repository. When the patches could not be applied, the error message will be replied to the user. The patches can have a maximum combined size of 2MB for now.
31 lines
742 B
Ruby
31 lines
742 B
Ruby
# 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
|