summaryrefslogtreecommitdiff
path: root/doPatch.go
diff options
context:
space:
mode:
authorJeff Carr <[email protected]>2025-09-25 16:24:08 -0500
committerJeff Carr <[email protected]>2025-09-25 16:24:08 -0500
commitd331af80e098dcead00b19b36eb607b0ad862690 (patch)
treec8d1a45401d795b5643bec853ce75bd9f82d3f5e /doPatch.go
parent92be907bce6fd28a1e49a54b318c2b44ffefaa2a (diff)
delete applied patches from PB filev0.25.30
Diffstat (limited to 'doPatch.go')
-rw-r--r--doPatch.go158
1 files changed, 89 insertions, 69 deletions
diff --git a/doPatch.go b/doPatch.go
index 8ac79f2..098aa20 100644
--- a/doPatch.go
+++ b/doPatch.go
@@ -100,86 +100,106 @@ func doPatch() error {
}
if argv.Patch.List != nil {
- var changed bool
- newpatches := new(forgepb.Set)
- newpatches.Patches = forgepb.NewPatches()
- for pset := range me.forge.Patchsets.IterAll() {
- pset.PrintTable()
- for patch := range pset.Patches.IterAll() {
+ return doPatchList()
+ }
+
+ // list patches by default
+ return doPatchList()
+}
+
+func doPatchList() error {
+ // if nothing selected, list the patches
+ var changed bool
+ newpatches := new(forgepb.Set)
+ newpatches.Patches = forgepb.NewPatches()
+ for pset := range me.forge.Patchsets.IterAll() {
+ pset.PrintTable()
+ if pset.Patches.Len() == 0 {
+ log.Info("pset is empty")
+ me.forge.Patchsets.Delete(pset)
+ changed = true
+ continue
+ }
+ for patch := range pset.Patches.IterAll() {
+ changed = true
+ if err := isPatchIdApplied(patch); err == nil {
+ log.Info("patchId already applied", patch.PatchId, patch.Filename)
+ pset.Patches.Delete(patch)
changed = true
- if patch.NewHash == "" || patch.NewHash == "na" {
- if newpatches.Patches.AppendByPatchId(patch) {
- log.Info("patchId added here", patch.PatchId)
- } else {
- log.Info("patchId already here", patch.PatchId)
- }
+ continue
+ }
+
+ if patch.NewHash == "" || patch.NewHash == "na" {
+ if newpatches.Patches.AppendByPatchId(patch) {
+ log.Info("patchId added here", patch.PatchId)
} else {
- if err := setNewCommitHash(patch); err != nil {
- log.Infof("%s bad check on patch failure %v\n", patch.Filename, err)
- return err
- }
- log.Info("newhash set already here", patch.PatchId, patch.NewHash)
+ log.Info("patchId already here", patch.PatchId)
+ pset.Patches.Delete(patch)
+ changed = true
}
+ } else {
+ if err := setNewCommitHash(patch); err != nil {
+ log.Infof("%s bad check on patch failure %v\n", patch.Filename, err)
+ return err
+ }
+ log.Info("newhash set already here", patch.PatchId, patch.NewHash)
}
}
- if changed {
- if err := me.forge.SavePatchsets(); err != nil {
- log.Warn("savePatchsets() failed", err)
- }
+ }
+ log.Info("NEW PATCHES TABLE")
+ newpatches.PrintTable()
+ for patch := range newpatches.Patches.IterAll() {
+ if err := setNewCommitHash(patch); err == nil {
+ log.Info("newhash set already here", patch.PatchId, patch.NewHash)
+ changed = true
+ continue
}
- log.Info("NEW PATCHES TABLE")
- newpatches.PrintTable()
- for patch := range newpatches.Patches.IterAll() {
- if err := setNewCommitHash(patch); err == nil {
- log.Info("newhash set already here", patch.PatchId, patch.NewHash)
- continue
- }
- log.Infof("%s is new\n", patch.Filename)
- repo := me.forge.FindByGoPath(patch.Namespace)
- if repo == nil {
- log.Info("\tCould not find namespace:", patch.Namespace)
- continue
- }
- if fhelp.QuestionUser("apply this patch?") {
- newhash, err := applyAndTrackPatch(repo, patch)
- log.Info("apply results:", newhash, err)
- }
+ log.Infof("%s is new\n", patch.Filename)
+ repo := me.forge.FindByGoPath(patch.Namespace)
+ if repo == nil {
+ log.Info("\tCould not find namespace:", patch.Namespace)
+ continue
}
- return nil
- /*
- if newpatches.Len() != 0 {
- for patch := range newpatches.IterAll() {
- log.Info("new patch:", patch.CommitHash, patch.NewHash, patch.Filename)
- repo := me.forge.FindByGoPath(patch.Namespace)
- if repo == nil {
- log.Info("\tCould not find namespace:", patch.Namespace)
- continue
- }
+ if fhelp.QuestionUser("apply this patch?") {
+ newhash, err := applyAndTrackPatch(repo, patch)
+ log.Info("apply results:", newhash, err)
+ }
+ }
+ if changed {
+ if err := me.forge.SavePatchsets(); err != nil {
+ log.Warn("savePatchsets() failed", err)
+ }
+ }
+ return nil
+ /*
+ if newpatches.Len() != 0 {
+ for patch := range newpatches.IterAll() {
+ log.Info("new patch:", patch.CommitHash, patch.NewHash, patch.Filename)
+ repo := me.forge.FindByGoPath(patch.Namespace)
+ if repo == nil {
+ log.Info("\tCould not find namespace:", patch.Namespace)
+ continue
}
- return log.Errorf("patches need to be applied")
}
+ return log.Errorf("patches need to be applied")
+ }
- // return doPatchList()
- applied := findApplied()
- if applied == nil || applied.Len() == 0 {
- log.Info("no patches have been appled to the devel branch yet")
- return nil
- }
- // for patch := range applied.IterAll() {
- // log.Info("SEND APPLIED: newhash:", patch.NewHash, "commithash:", patch.CommitHash, "patch", patch.Namespace)
- // }
- newpb, _, err := applied.HttpPostVerbose(myServer(), "applied")
- if err != nil {
- return err
- }
- newpb.PrintTable()
+ // return doPatchList()
+ applied := findApplied()
+ if applied == nil || applied.Len() == 0 {
+ log.Info("no patches have been appled to the devel branch yet")
return nil
- */
- }
-
- // if nothing, show patches & dirty repos
- me.forge.Patchsets.PrintTable()
- showWorkRepos()
+ }
+ // for patch := range applied.IterAll() {
+ // log.Info("SEND APPLIED: newhash:", patch.NewHash, "commithash:", patch.CommitHash, "patch", patch.Namespace)
+ // }
+ newpb, _, err := applied.HttpPostVerbose(myServer(), "applied")
+ if err != nil {
+ return err
+ }
+ newpb.PrintTable()
+ return nil
+ */
return nil
}