summaryrefslogtreecommitdiff
path: root/applyPatch.go
diff options
context:
space:
mode:
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 9dccc6c..5c1ee12 100644
--- a/applyPatch.go
+++ b/applyPatch.go
@@ -4,17 +4,30 @@ package main
import (
"os"
+ "path/filepath"
"go.wit.com/lib/protobuf/forgepb"
"go.wit.com/log"
)
func applyPatches(pset *forgepb.Patchs) error {
+ // log.Info("got to applyPatches() pset", pset)
+ log.Info("got to applyPatches() name", pset.Name)
+ log.Info("got to applyPatches() comment", pset.Comment)
all := pset.SortByFilename()
for all.Scan() {
p := all.Next()
- log.Info("pset filename", p.Filename)
+ // log.Info("pset filename FILENAME IS REAL?", p.Filename, pset.Name, pset.Comment)
+ 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)
+ raw.Write(p.Data)
+ raw.Close()
}
+ log.Info("THIS IS THE END MY FRIEND")
return nil
}
@@ -24,12 +37,24 @@ func readPatchFile(pbfile string) (*forgepb.Patchs, error) {
log.Info("readfile error", pbfile, err)
return nil, err
}
+ return handleBytes(bytes)
+}
+
+func handleBytes(bytes []byte) (*forgepb.Patchs, error) {
var pset *forgepb.Patchs
pset = new(forgepb.Patchs)
- err = pset.Unmarshal(bytes)
+ err := pset.Unmarshal(bytes)
if err != nil {
- log.Info("Unmarshal failed", pbfile, err)
+ log.Info("Unmarshal failed", err)
return nil, err
}
return pset, nil
}
+
+func doit(bytes []byte) error {
+ pset, err := handleBytes(bytes)
+ if err != nil {
+ return err
+ }
+ return applyPatches(pset)
+}