forked from tangled.org/core
this repo has no description

knotserver: git/merge: remove `GitRepo.Merge`

this method is not used now and should be replaced with
`MergeWithOptions`

Signed-off-by: Seongmin Lee <boltlessengineer@proton.me>

authored by boltless.me and committed by Tangled 033886cc 3c066500

Changed files
+8 -21
knotserver
git
xrpc
+7 -20
knotserver/git/merge.go
··· 160 return nil 161 } 162 163 - func (g *GitRepo) applyPatch(tmpDir, patchFile string, opts *MergeOptions) error { 164 var stderr bytes.Buffer 165 var cmd *exec.Cmd 166 167 // if patch is a format-patch, apply using 'git am' 168 if opts.FormatPatch { 169 - amCmd := exec.Command("git", "-C", tmpDir, "am", patchFile) 170 - amCmd.Stderr = &stderr 171 - if err := amCmd.Run(); err != nil { 172 - return fmt.Errorf("patch application failed: %s", stderr.String()) 173 - } 174 - return nil 175 - } 176 - 177 - // else, apply using 'git apply' and commit it manually 178 - exec.Command("git", "-C", tmpDir, "config", "advice.mergeConflict", "false").Run() 179 - if opts != nil { 180 applyCmd := exec.Command("git", "-C", tmpDir, "apply", patchFile) 181 applyCmd.Stderr = &stderr 182 if err := applyCmd.Run(); err != nil { ··· 213 } 214 215 cmd = exec.Command("git", commitArgs...) 216 - } else { 217 - // If no commit message specified, use git-am which automatically creates a commit 218 - cmd = exec.Command("git", "-C", tmpDir, "am", patchFile) 219 } 220 221 cmd.Stderr = &stderr ··· 255 return result 256 } 257 258 - func (g *GitRepo) Merge(patchData []byte, targetBranch string) error { 259 - return g.MergeWithOptions(patchData, targetBranch, nil) 260 - } 261 - 262 - func (g *GitRepo) MergeWithOptions(patchData []byte, targetBranch string, opts *MergeOptions) error { 263 patchFile, err := g.createTempFileWithPatch(patchData) 264 if err != nil { 265 return &ErrMerge{
··· 160 return nil 161 } 162 163 + func (g *GitRepo) applyPatch(tmpDir, patchFile string, opts MergeOptions) error { 164 var stderr bytes.Buffer 165 var cmd *exec.Cmd 166 + 167 + exec.Command("git", "-C", tmpDir, "config", "advice.mergeConflict", "false").Run() 168 169 // if patch is a format-patch, apply using 'git am' 170 if opts.FormatPatch { 171 + cmd = exec.Command("git", "-C", tmpDir, "am", patchFile) 172 + } else { 173 + // else, apply using 'git apply' and commit it manually 174 applyCmd := exec.Command("git", "-C", tmpDir, "apply", patchFile) 175 applyCmd.Stderr = &stderr 176 if err := applyCmd.Run(); err != nil { ··· 207 } 208 209 cmd = exec.Command("git", commitArgs...) 210 } 211 212 cmd.Stderr = &stderr ··· 246 return result 247 } 248 249 + func (g *GitRepo) MergeWithOptions(patchData []byte, targetBranch string, opts MergeOptions) error { 250 patchFile, err := g.createTempFileWithPatch(patchData) 251 if err != nil { 252 return &ErrMerge{
+1 -1
knotserver/xrpc/merge.go
··· 67 return 68 } 69 70 - mo := &git.MergeOptions{} 71 if data.AuthorName != nil { 72 mo.AuthorName = *data.AuthorName 73 }
··· 67 return 68 } 69 70 + mo := git.MergeOptions{} 71 if data.AuthorName != nil { 72 mo.AuthorName = *data.AuthorName 73 }