start working on 'git am'

This commit is contained in:
Jeff Carr 2024-12-30 02:03:56 -06:00
parent 4fc958fcc9
commit c25a7ea736
1 changed files with 28 additions and 3 deletions

View File

@ -6,11 +6,17 @@ import (
"os" "os"
"path/filepath" "path/filepath"
"go.wit.com/lib/gui/shell"
"go.wit.com/lib/protobuf/forgepb" "go.wit.com/lib/protobuf/forgepb"
"go.wit.com/log" "go.wit.com/log"
) )
func applyPatches(pset *forgepb.Patchs) error { func applyPatches(pset *forgepb.Patchs) error {
var everythingworked bool = true
tmpdir, err := os.MkdirTemp("", "forge")
if err != nil {
return err
}
// log.Info("got to applyPatches() pset", pset) // log.Info("got to applyPatches() pset", pset)
log.Info("applyPatches() NAME", pset.Name) log.Info("applyPatches() NAME", pset.Name)
log.Info("applyPatches() COMMENT", pset.Comment) log.Info("applyPatches() COMMENT", pset.Comment)
@ -23,11 +29,30 @@ func applyPatches(pset *forgepb.Patchs) error {
basepath, filename := filepath.Split(p.Filename) basepath, filename := filepath.Split(p.Filename)
fullpath := filepath.Join(me.forge.GetGoSrc(), basepath) fullpath := filepath.Join(me.forge.GetGoSrc(), basepath)
log.Info("pset filename FILENAME IS REAL? fullpath", fullpath) log.Info("pset filename FILENAME IS REAL? fullpath", fullpath)
log.Info("pset filename FILENAME IS REAL? filename", filename) fullTmpdir := filepath.Join(tmpdir, basepath)
fullname := filepath.Join(fullpath, filename) err := os.MkdirAll(fullTmpdir, os.ModePerm)
raw, _ := os.OpenFile(fullname, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0644) if err != nil {
log.Info("applyPathces() MkdirAll failed for", fullTmpdir)
log.Info("applyPathces() MkdirAll failed err", err)
everythingworked = false
continue
}
log.Info("pset filename FILENAME IS REAL? tmp fullTmpdir", fullTmpdir)
tmpname := filepath.Join(fullTmpdir, filename)
raw, _ := os.OpenFile(tmpname, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0644)
raw.Write(p.Data) raw.Write(p.Data)
raw.Close() raw.Close()
cmd := []string{"git", "am", tmpname}
result := shell.PathRun(fullpath, cmd)
if result.Exit != 0 {
log.Info("cmd failed", cmd, result.Exit)
everythingworked = false
}
// until 'git am' works
everythingworked = false
}
if everythingworked {
os.RemoveAll(tmpdir) // clean up
} }
log.Info("THIS IS THE END MY FRIEND") log.Info("THIS IS THE END MY FRIEND")
return nil return nil