summaryrefslogtreecommitdiff
path: root/doMerge.go
diff options
context:
space:
mode:
authorJeff Carr <[email protected]>2025-08-28 15:01:15 -0500
committerJeff Carr <[email protected]>2025-08-28 19:30:59 -0500
commit684c5b1dad1ebaa6a9443641e65e2789c3c85911 (patch)
treedaf3a4c0ecfed3579384648f3de833fb9eb6d555 /doMerge.go
parent7a547a203dffc756e1c52985fee846c4506596a5 (diff)
kinda merges repos
Diffstat (limited to 'doMerge.go')
-rw-r--r--doMerge.go36
1 files changed, 27 insertions, 9 deletions
diff --git a/doMerge.go b/doMerge.go
index 784b213..be34b8f 100644
--- a/doMerge.go
+++ b/doMerge.go
@@ -16,9 +16,7 @@ func doMerge() error {
}
mergePatchsets()
- for pset := range me.all.IterAll() {
- showPatchsets(pset)
- }
+
if err := savePatchsets(); err != nil {
log.Warn("savePatchsets() failed", err)
return err
@@ -28,16 +26,35 @@ func doMerge() error {
// adds submitted patches not specifically assigned to a patchset
// to the generic patchset called "forge auto commit"
-func addRandomPatch(patch *forgepb.Patch) {
+func addRandomPatch(patch *forgepb.Patch) error {
+ var fauto *forgepb.Patchset
+
+ // ignore patch if it's already here
+ if findPatch(patch) {
+ log.Info("already found patch", patch.CommitHash, patch.Namespace)
+ return nil
+ }
for pset := range me.all.IterAll() {
if pset.Name == "forge auto commit" {
- newpb := proto.Clone(patch).(*forgepb.Patch)
- if newpb != nil {
- pset.Patches.Append(newpb)
- }
+ fauto = pset
+ break
}
}
- log.Warn("patchset.Name == 'forge auto commit' could not be found so the patch in", patch.Namespace, "could not be added")
+
+ if fauto == nil {
+ fauto = new(forgepb.Patchset)
+ fauto.Name = "forge auto commit"
+ fauto.Patches = forgepb.NewPatches()
+ me.all.Patchsets = append(me.all.Patchsets, fauto)
+ log.Warn("had to create 'forge auto commit' patchset")
+ // return log.Errorf("no default place yet")
+ }
+ newpb := proto.Clone(patch).(*forgepb.Patch)
+ if newpb == nil {
+ return log.Errorf("proto.Clone returned nil")
+ }
+ fauto.Patches.Patches = append(fauto.Patches.Patches, newpb)
+ return nil
}
func addPatchset(filename string, pb *forgepb.Patchset) {
@@ -54,6 +71,7 @@ func addPatchset(filename string, pb *forgepb.Patchset) {
// log.Info("\talready found!!!!!!!", pset.Uuid, patch.Namespace)
} else {
log.Info("\tnew patch:", filename, pb.Name, pb.Comment, author)
+ addRandomPatch(patch)
}
}
// add each of the patches to the general pool