summaryrefslogtreecommitdiff
path: root/doPatches.go
diff options
context:
space:
mode:
Diffstat (limited to 'doPatches.go')
-rw-r--r--doPatches.go84
1 files changed, 84 insertions, 0 deletions
diff --git a/doPatches.go b/doPatches.go
new file mode 100644
index 0000000..cc06c03
--- /dev/null
+++ b/doPatches.go
@@ -0,0 +1,84 @@
+package main
+
+import (
+ "go.wit.com/lib/fhelp"
+ "go.wit.com/lib/protobuf/forgepb"
+ "go.wit.com/log"
+)
+
+func doPatches() error {
+ if argv.Patch.List != nil {
+ log.Printf("forge.Init() %s len()=%d\n", me.forge.Config.Filename, me.forge.Repos.Len())
+ fhelp.DumpENV("finit:")
+ me.forge.Config.DumpENV()
+ return doList()
+ }
+
+ if argv.Patch.Clean != nil {
+ log.Printf("forge.Init() %s len()=%d\n", me.forge.Config.Filename, me.forge.Repos.Len())
+ fhelp.DumpENV("finit:")
+ me.forge.Config.DumpENV()
+ return doClean()
+ }
+
+ return nil
+}
+
+func doList() error {
+ log.Infof("do list here. Patchsets.Len()=%d\n", me.forge.Patchsets.Len())
+ for pset := range me.forge.Patchsets.IterAll() {
+ pset.PrintTable()
+ }
+ return nil
+}
+
+func doClean() error {
+ log.Infof("clean Patchsets.Len()=%d\n", me.forge.Patchsets.Len())
+ // show all the patchsets with Names
+ for pset := range me.forge.Patchsets.IterAll() {
+ for patch := range pset.Patches.IterAll() {
+ if patch.PatchId == "" {
+ log.Info("Delete", patch.CommitHash, patch.PatchId, patch.Namespace)
+ pset.Patches.Delete(patch)
+ } else {
+ log.Info("\t", patch.CommitHash, patch.PatchId, patch.Namespace)
+ }
+ }
+ }
+ me.forge.SavePatchsets()
+ return nil
+}
+
+// returns true if the patch already exists in the protobuf
+func findPatch(newpatch *forgepb.Patch) bool {
+ // log.Info("\tlook for patch:", newpatch.CommitHash, newpatch.Namespace)
+
+ for pset := range me.forge.Patchsets.IterAll() {
+ for _, patch := range pset.Patches.Patches {
+ if patch.CommitHash == newpatch.CommitHash {
+ // log.Info("\tfound pset!!!!!!", pset.Uuid, patch.Namespace)
+ return true
+ }
+
+ }
+ }
+
+ return false
+}
+
+// returns true if the patch already exists in the protobuf
+func expirePatch(newpatch *forgepb.Patch) bool {
+ // log.Info("\tlook for patch:", newpatch.CommitHash, newpatch.Namespace)
+
+ for pset := range me.forge.Patchsets.IterAll() {
+ for _, patch := range pset.Patches.Patches {
+ if patch.CommitHash == newpatch.CommitHash {
+ patch.NewHash = newpatch.NewHash
+ // log.Info("\tfound pset!!!!!!", pset.Uuid, patch.Namespace)
+ return true
+ }
+
+ }
+ }
+ return false
+}