summaryrefslogtreecommitdiff
path: root/windowPatches.go
diff options
context:
space:
mode:
authorJeff Carr <[email protected]>2025-10-07 02:36:53 -0500
committerJeff Carr <[email protected]>2025-10-07 02:36:53 -0500
commit4ae05c8f12c4a2f6e8be3bf69072d1ca6459854c (patch)
treeaf3bc72e22c0037c0796b4b433b3beb402af2f48 /windowPatches.go
parent957f860213c582970d458544cb6b3956da468cd7 (diff)
ready to purge old codev0.25.62
Diffstat (limited to 'windowPatches.go')
-rw-r--r--windowPatches.go52
1 files changed, 1 insertions, 51 deletions
diff --git a/windowPatches.go b/windowPatches.go
index fa1d299..65f54b7 100644
--- a/windowPatches.go
+++ b/windowPatches.go
@@ -12,7 +12,6 @@ import (
"go.wit.com/gui"
"go.wit.com/lib/gadgets"
"go.wit.com/lib/protobuf/forgepb"
- "go.wit.com/lib/protobuf/gitpb"
"go.wit.com/log"
)
@@ -90,7 +89,7 @@ func applyPatchNew(p *forgepb.Patch) error {
log.Info("Could not figure out repo path", rn)
return log.Errorf("%s namespace?\n", rn)
}
- if _, err := applyAndTrackPatch(repo, p); err != nil {
+ if _, err := applyPatch(repo, p); err != nil {
cmd := []string{"git", "am", "--abort"}
err := repo.RunVerbose(cmd)
log.Info("warn user of git am error", err)
@@ -158,12 +157,6 @@ func AddPatchesPB(tbox *gui.Node, pb *forgepb.Patches) *forgepb.PatchesTable {
return t
}
-func applyPatch(repo *gitpb.Repo, filename string) error {
- cmd := []string{"git", "am", filename}
- err := repo.RunVerbose(cmd)
- return err
-}
-
func savePatch(p *forgepb.Patch) (string, error) {
_, filen := filepath.Split(p.Filename)
tmpname := filepath.Join("/tmp", filen)
@@ -177,46 +170,3 @@ func savePatch(p *forgepb.Patch) (string, error) {
return tmpname, nil
}
-
-func applyAndTrackPatch(repo *gitpb.Repo, p *forgepb.Patch) (string, error) {
- _, filen := filepath.Split(p.Filename)
- tmpname := filepath.Join("/tmp", filen)
- log.Info("saving as", tmpname, p.Filename)
- raw, err := os.OpenFile(tmpname, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0644)
- if err != nil {
- return "", err
- }
- raw.Write(p.Data)
- raw.Close()
-
- cmd := []string{"git", "am", tmpname}
- err = repo.RunVerbose(cmd)
- if err != nil {
- log.Info("git am failed. run 'git am --abort' here")
- return "", log.Errorf("git am failed")
- }
-
- log.Info("Try to find hash value now")
-
- p.NewHash = "fixme applyAndTrack"
- if setNewHash(p, p.NewHash) {
- log.Info("setting NewHash worked", p.NewHash)
- }
- me.forge.SavePatchsets()
-
- return p.NewHash, log.Errorf("did not lookup new hash")
-}
-
-func setNewHash(p *forgepb.Patch, hash string) bool {
- for pset := range me.forge.Patchsets.IterAll() {
- for patch := range pset.Patches.IterAll() {
- if patch.CommitHash == hash {
- patch.NewHash = hash
- log.Info("found patch in repo")
- me.forge.SavePatchsets()
- return true
- }
- }
- }
- return false
-}