summaryrefslogtreecommitdiff
path: root/patchset.config.go
diff options
context:
space:
mode:
authorJeff Carr <[email protected]>2025-09-07 19:14:38 -0500
committerJeff Carr <[email protected]>2025-09-07 21:41:20 -0500
commitecf404994754b339e6e3fce1fceda7f0e0734d7c (patch)
tree8928eb7b9d94ba02ac11a3f10226d6575392d7ab /patchset.config.go
parente3c8669be446ec3529ea924ccd0034cd44dae170 (diff)
start using a standard http PB
Diffstat (limited to 'patchset.config.go')
-rw-r--r--patchset.config.go52
1 files changed, 34 insertions, 18 deletions
diff --git a/patchset.config.go b/patchset.config.go
index 4a27726..fd9b509 100644
--- a/patchset.config.go
+++ b/patchset.config.go
@@ -96,6 +96,20 @@ func (pb *Patchset) ShowPatchsets() error {
return nil
}
+// adds a patch. returns true if patch is new
+func (f *Forge) AddPatch(patch *Patch) bool {
+ if f.findPatch(patch) {
+ // log.Info("\talready found!!!!!!!", pset.Uuid, patch.Namespace)
+ return false
+ }
+ if f.AddNewPatch(patch) {
+ log.Info("\tnew patch added:", patch.CommitHash, patch.Gs, patch.Gae, patch.Gan)
+ return true
+ }
+ log.Info("\tnew patch failed:", patch.CommitHash, patch.Gs)
+ return false
+}
+
// adds a patchset or just the patches
func (f *Forge) AddPatchset(pb *Patchset) bool {
var changed bool
@@ -111,11 +125,11 @@ func (f *Forge) AddPatchset(pb *Patchset) bool {
if f.findPatch(patch) {
// log.Info("\talready found!!!!!!!", pset.Uuid, patch.Namespace)
} else {
- if err := f.addRandomPatch(patch); err == nil {
+ if f.AddNewPatch(patch) {
log.Info("\tnew patch added:", patch.CommitHash, pb.Name, pb.Comment, author)
changed = true
} else {
- log.Info("\tnew patch failed:", patch.CommitHash, pb.Name, pb.Comment, author, err)
+ log.Info("\tnew patch failed:", patch.CommitHash, pb.Name, pb.Comment, author)
}
}
@@ -153,33 +167,35 @@ func (f *Forge) findAutoPatchset() *Patchset {
var fauto *Patchset
log.Warn("findAutoPatchset() had to create 'forge auto commit'")
if fauto == nil {
- fauto = new(Patchset)
- fauto.Name = "forge auto commit"
- fauto.Patches = NewPatches()
- fauto.Uuid = uuid.New().String()
- f.Patchsets.Patchsets = append(f.Patchsets.Patchsets, fauto)
+ fauto = makeDefaultPatchset()
+ f.Patchsets.Append(fauto)
}
return fauto
}
-// adds submitted patches not specifically assigned to a patchset
-// to the generic patchset called "forge auto commit"
-func (f *Forge) addRandomPatch(patch *Patch) error {
+func makeDefaultPatchset() *Patchset {
+ fauto := new(Patchset)
+ fauto.Name = "forge auto commit"
+ fauto.Patches = NewPatches()
+ fauto.Uuid = uuid.New().String()
+ return fauto
+}
+
+// adds submitted patches not
+// If the patch was actually new, return true
+func (f *Forge) AddNewPatch(patch *Patch) bool {
// ignore patch if it's already here
if f.findPatch(patch) {
log.Info("already found patch", patch.CommitHash, patch.Namespace)
- return nil
+ return false
}
fauto := f.findAutoPatchset()
if fauto == nil {
- return log.Errorf("no default place yet")
+ // should have made the default patchset
+ return false
}
- newpb := proto.Clone(patch).(*Patch)
- if newpb == nil {
- return log.Errorf("proto.Clone returned nil")
- }
- fauto.Patches.Patches = append(fauto.Patches.Patches, newpb)
- return nil
+ fauto.Patches.Append(patch)
+ return true
}
// returns true if the patch already exists in the protobuf