summaryrefslogtreecommitdiff
path: root/applyPatch.go
diff options
context:
space:
mode:
authorJeff Carr <[email protected]>2024-12-30 02:03:56 -0600
committerJeff Carr <[email protected]>2024-12-30 02:03:56 -0600
commitc25a7ea736aa4848de7eb6a5efe6124a87c39deb (patch)
treee64d55ee327428b73e1d9bd46c571038aaf6aa85 /applyPatch.go
parent4fc958fcc9069211260d6b2ebf0b6ef9ce0398d6 (diff)
start working on 'git am'v0.22.34v0.22.33
Diffstat (limited to 'applyPatch.go')
-rw-r--r--applyPatch.go31
1 files changed, 28 insertions, 3 deletions
diff --git a/applyPatch.go b/applyPatch.go
index 0985345..a0ddbab 100644
--- a/applyPatch.go
+++ b/applyPatch.go
@@ -6,11 +6,17 @@ import (
"os"
"path/filepath"
+ "go.wit.com/lib/gui/shell"
"go.wit.com/lib/protobuf/forgepb"
"go.wit.com/log"
)
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("applyPatches() NAME", pset.Name)
log.Info("applyPatches() COMMENT", pset.Comment)
@@ -23,11 +29,30 @@ func applyPatches(pset *forgepb.Patchs) error {
basepath, filename := filepath.Split(p.Filename)
fullpath := filepath.Join(me.forge.GetGoSrc(), basepath)
log.Info("pset filename FILENAME IS REAL? fullpath", fullpath)
- log.Info("pset filename FILENAME IS REAL? filename", filename)
- fullname := filepath.Join(fullpath, filename)
- raw, _ := os.OpenFile(fullname, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0644)
+ fullTmpdir := filepath.Join(tmpdir, basepath)
+ err := os.MkdirAll(fullTmpdir, os.ModePerm)
+ 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.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")
return nil