Add an endpoint to apply patches to a branch
This adds an RPC that takes a branch and a stream of patches generated
using git format-patch
, the patches are applied to the branch using
git am
.
When the specified branch does not exist, it will be created from HEAD, if it existed, the patches will be applied to that branch.
If the patches could not be applied, a gRPC FailedPrecondition
is
raised.
To apply the patches, a random new temporary branch is created from either the specified branch or HEAD. That branch is checked out in a worktree and we attempt to apply the patches. If it succeeds, then we update the specified branch to the new revision. After the attempt, we remove the temporary branch.
The response of the RPC is a BranchUpdate
response containing
whether or not a new branch was created, and the new tip of the
branch.
Related proto-change: gitaly-proto!232 (merged) Required for: https://gitlab.com/gitlab-org/gitlab-ce/issues/40830