summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeff Carr <[email protected]>2025-09-07 22:47:26 -0500
committerJeff Carr <[email protected]>2025-09-07 22:48:58 -0500
commit5e71dd3ecc32d2eb2c81825c7c14e4cc6e1c747d (patch)
tree51c9d7640609302e42685fd143c24ae8293931eb
parent873cb39932ae90fa9dac5415b08fd687c8ef3199 (diff)
add "/applied" and "/merged" routesv0.0.24
-rw-r--r--doList.go17
-rw-r--r--handlePatches.go10
-rw-r--r--http.go7
3 files changed, 34 insertions, 0 deletions
diff --git a/doList.go b/doList.go
index 09068cc..149ecc0 100644
--- a/doList.go
+++ b/doList.go
@@ -34,3 +34,20 @@ func findPatch(newpatch *forgepb.Patch) bool {
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
+}
diff --git a/handlePatches.go b/handlePatches.go
index d5b12a9..a968b7b 100644
--- a/handlePatches.go
+++ b/handlePatches.go
@@ -19,6 +19,16 @@ func addNewPatches(pb *forgepb.Patches, reqPB *httppb.HttpRequest) *forgepb.Patc
return newPatchesPB
}
+func handleMergedPatches(pb *forgepb.Patches, reqPB *httppb.HttpRequest) *forgepb.Patches {
+ newPatchesPB := new(forgepb.Patches)
+ for newpatch := range pb.IterAll() {
+ if expirePatch(newpatch) {
+ newPatchesPB.Append(newpatch)
+ }
+ }
+ return newPatchesPB
+}
+
func sendPendingPatches(pb *forgepb.Patches, reqPB *httppb.HttpRequest) *forgepb.Patches {
allPatchesPB := new(forgepb.Patches)
for pset := range me.forge.Patchsets.IterAll() {
diff --git a/http.go b/http.go
index 11c0a49..2404ca6 100644
--- a/http.go
+++ b/http.go
@@ -114,6 +114,13 @@ func okHandler(w http.ResponseWriter, r *http.Request) {
case "/patches/new":
result = addNewPatches(pb, reqPB)
log.Infof("addNewPatches() pb.Len()=%d result.Len()=%d\n", pb.Len(), result.Len())
+ case "/patches/applied":
+ log.Info("not really anything needs to be done on applied patches?")
+ // result = handleAppliedPatches(pb, reqPB)
+ case "/patches/merged":
+ log.Info("a maintainer has merged these patches")
+ result = handleMergedPatches(pb, reqPB)
+ // result = handleAppliedPatches(pb, reqPB)
case "/patches/get":
result = sendPendingPatches(pb, reqPB)
default: