Monorepo for Tangled tangled.org

knotserver/git: rework merge check to also use git am #1033

merged opened by oppi.li targeting master from op/rlrsyllrmmrk

we were using git apply in merge check and git am for the actual merge, but in reality, there are slight behavior changes among the two. this change switches out git apply in mergeCheck to use git am when dealing with mailbox style patches.

Signed-off-by: oppiliappan me@oppi.li

Labels

None yet.

assignee

None yet.

Participants 1
AT URI
at://did:plc:qfpnj4og54vl56wngdriaxug/sh.tangled.repo.pull/3mdifrzrs2722
+5 -5
Interdiff #0 โ†’ #1
+5 -5
knotserver/git/merge.go
··· 107 107 return fmt.Sprintf("merge failed: %s", e.Message) 108 108 } 109 109 110 - func createTempFileWithPatch(patchData string) (string, error) { 110 + func createTemp(data string) (string, error) { 111 111 tmpFile, err := os.CreateTemp("", "git-patch-*.patch") 112 112 if err != nil { 113 113 return "", fmt.Errorf("failed to create temporary patch file: %w", err) 114 114 } 115 115 116 - if _, err := tmpFile.Write([]byte(patchData)); err != nil { 116 + if _, err := tmpFile.Write([]byte(data)); err != nil { 117 117 tmpFile.Close() 118 118 os.Remove(tmpFile.Name()) 119 119 return "", fmt.Errorf("failed to write patch data to temporary file: %w", err) ··· 230 230 } 231 231 232 232 func (g *GitRepo) applySingleMailbox(singlePatch types.FormatPatch) (plumbing.Hash, error) { 233 - tmpPatch, err := createTempFileWithPatch(singlePatch.Raw) 233 + tmpPatch, err := createTemp(singlePatch.Raw) 234 234 if err != nil { 235 235 return plumbing.ZeroHash, fmt.Errorf("failed to create temporary patch file for singluar mailbox patch: %w", err) 236 236 } ··· 324 324 return val 325 325 } 326 326 327 - patchFile, err := createTempFileWithPatch(patchData) 327 + patchFile, err := createTemp(patchData) 328 328 if err != nil { 329 329 return &ErrMerge{ 330 330 Message: err.Error(), ··· 353 353 } 354 354 355 355 func (g *GitRepo) MergeWithOptions(patchData string, targetBranch string, opts MergeOptions) error { 356 - patchFile, err := createTempFileWithPatch(patchData) 356 + patchFile, err := createTemp(patchData) 357 357 if err != nil { 358 358 return &ErrMerge{ 359 359 Message: err.Error(),
knotserver/xrpc/merge_check.go

This file has not been changed.

History

2 rounds 0 comments
sign up or login to add to the discussion
oppi.li submitted #1
1 commit
expand
knotserver/git: rework merge check to also use git am
2/3 timeout, 1/3 success
expand
expand 0 comments
pull request successfully merged
oppi.li submitted #0
1 commit
expand
knotserver/git: rework merge check to also use git am
2/3 timeout, 1/3 success
expand
expand 0 comments