+7
-20
knotserver/git/merge.go
+7
-20
knotserver/git/merge.go
···
160
160
return nil
161
161
}
162
162
163
-
func (g *GitRepo) applyPatch(tmpDir, patchFile string, opts *MergeOptions) error {
163
+
func (g *GitRepo) applyPatch(tmpDir, patchFile string, opts MergeOptions) error {
164
164
var stderr bytes.Buffer
165
165
var cmd *exec.Cmd
166
+
167
+
exec.Command("git", "-C", tmpDir, "config", "advice.mergeConflict", "false").Run()
166
168
167
169
// if patch is a format-patch, apply using 'git am'
168
170
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 {
171
+
cmd = exec.Command("git", "-C", tmpDir, "am", patchFile)
172
+
} else {
173
+
// else, apply using 'git apply' and commit it manually
180
174
applyCmd := exec.Command("git", "-C", tmpDir, "apply", patchFile)
181
175
applyCmd.Stderr = &stderr
182
176
if err := applyCmd.Run(); err != nil {
···
213
207
}
214
208
215
209
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
210
}
220
211
221
212
cmd.Stderr = &stderr
···
255
246
return result
256
247
}
257
248
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 {
249
+
func (g *GitRepo) MergeWithOptions(patchData []byte, targetBranch string, opts MergeOptions) error {
263
250
patchFile, err := g.createTempFileWithPatch(patchData)
264
251
if err != nil {
265
252
return &ErrMerge{