attempt git am --abort

This commit is contained in:
Jeff Carr 2025-08-17 23:24:37 -05:00
parent 212c706e14
commit 631544356a
2 changed files with 4 additions and 42 deletions

View File

@ -8,7 +8,6 @@ import (
"path/filepath"
"strings"
"go.wit.com/lib/gui/shell"
"go.wit.com/lib/protobuf/forgepb"
"go.wit.com/lib/protobuf/gitpb"
"go.wit.com/log"
@ -70,47 +69,6 @@ func countCurrentPatches(repo *gitpb.Repo) int {
return len(result.Stdout)
}
func applyPatchsetOLD(pset *forgepb.Patchset) error {
var everythingworked bool = true
tmpdir, err := os.MkdirTemp("", "forge")
if err != nil {
return err
}
// log.Info("got to applyPatches() pset", pset)
log.Info("applyPatches() NAME", pset.Name)
log.Info("applyPatches() COMMENT", pset.Comment)
log.Info("applyPatches() GIT_AUTHOR_NAME", pset.GetGitAuthorName())
log.Info("applyPatches() GIT_AUTHOR_EMAIL", pset.GetGitAuthorEmail())
all := pset.Patches.SortByFilename()
for all.Scan() {
p := all.Next()
basedir := me.forge.GetGoSrc()
if fullname, err := savePatchFile(p, basedir); err != nil {
log.Info(fullname, "save failed", err)
continue
} else {
basedir, filename := filepath.Split(fullname)
cmd := []string{"git", "am", filename}
log.Info("Should run: at", basedir, ":", cmd)
log.Info(basedir, filename)
result := shell.PathRun(basedir, cmd)
for _, line := range result.Stdout {
log.Warn("stdout:", line)
}
for _, line := range result.Stderr {
log.Warn("stderr:", line)
}
}
everythingworked = false
}
if everythingworked {
os.RemoveAll(tmpdir) // clean up
}
log.Info("THIS IS THE END MY FRIEND")
return nil
}
func savePatchFile(p *forgepb.Patch, basedir string) (string, error) {
basepath, filename := filepath.Split(p.Filename)
fulldir := filepath.Join(basedir, basepath)

View File

@ -94,6 +94,8 @@ func makePatchesWin(patches *forgepb.Patches) *stdPatchTableWin {
}
count += 1
if err := applyPatch(repo, filename); err != nil {
cmd := []string{"git", "am", "--abort"}
err := repo.RunVerbose(cmd)
log.Info("warn user of git am error", err)
return
}
@ -124,6 +126,8 @@ func applyPatchNew(p *forgepb.Patch) error {
}
if err := applyPatch(repo, filename); err != nil {
log.Info("warn user of git am error", err)
cmd := []string{"git", "am", "--abort"}
err := repo.RunVerbose(cmd)
return err
}
return nil