summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile2
-rw-r--r--doMerge.go36
2 files changed, 28 insertions, 10 deletions
diff --git a/Makefile b/Makefile
index 6b9c77b..760b411 100644
--- a/Makefile
+++ b/Makefile
@@ -5,7 +5,7 @@ BUILDTIME = $(shell date +%Y.%m.%d_%H%M)
all: install
forged merge
- # forged list
+ forged list
build: goimports
GO111MODULE=off go build \
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