Skip to content

Port UserApplyPatch to Go

Sami Hiltunen requested to merge smh-port-user-apply-patch into master

This MR adds a Go port of UserApplyPatch.

UserApplyPatch is an RPC that parses a stream of patches in unix mailbox format, applies them sequentially on top of the base commit and sets the target branch to point to the resulting commit.

The original Ruby implementation basically just streamed the patches to git am. The Go port uses the same approach although returns more descriptive errors when the command fails.

The RPC does not support setting a base branch. The Go implementation follows the same default branch discovery for determining the base commit as the Ruby implementation. Notably, neither support creating the first branch in the repository.

This was initially implemented using a libgit2. During the implementation, a bug was discovered in the patching routine. As the fix wasn't merged upstream in a long time, we've implemented this using a worktree for now to unblock the efforts to remove the Ruby sidecar.

Closes #3076 (closed)

Edited by Sami Hiltunen

Merge request reports