summaryrefslogtreecommitdiff
path: root/windowPatchsets.go
diff options
context:
space:
mode:
Diffstat (limited to 'windowPatchsets.go')
-rw-r--r--windowPatchsets.go73
1 files changed, 40 insertions, 33 deletions
diff --git a/windowPatchsets.go b/windowPatchsets.go
index 36ee7ba..4251a19 100644
--- a/windowPatchsets.go
+++ b/windowPatchsets.go
@@ -36,6 +36,37 @@ func (w *stdPatchsetTableWin) Toggle() {
w.win.Toggle()
}
+func loadUpstreamPatchsets() {
+ psets, err := me.forge.GetPatchesets()
+ if err != nil {
+ log.Info("Get Patchsets failed", err)
+ return
+ }
+
+ var foundnew bool
+ all := psets.All()
+ for all.Scan() {
+ pset := all.Next()
+ found := me.psets.FindByUuid(pset.Uuid)
+ if found == nil {
+ log.Info("new patchset", pset.Name, pset.Uuid)
+ pset.State = "new"
+ foundnew = true
+ } else {
+ log.Info("patchset already on disk", found.Name, found.State)
+ pset.State = found.State
+ if pset.State == "" {
+ pset.State = "new"
+ }
+ }
+ }
+ if foundnew {
+ log.Info("should save these here")
+ me.psets = psets
+ savePatchsets()
+ }
+}
+
func makePatchsetsWin() *stdPatchsetTableWin {
dwin := new(stdPatchsetTableWin)
dwin.win = gadgets.NewGenericWindow("forge current patchsets", "patchset options")
@@ -54,35 +85,8 @@ func makePatchsetsWin() *stdPatchsetTableWin {
})
grid.NewButton("upstream", func() {
- psets, err := me.forge.GetPatchesets()
- if err != nil {
- log.Info("Get Patchsets failed", err)
- return
- }
-
- var foundnew bool
- all := psets.All()
- for all.Scan() {
- pset := all.Next()
- found := me.psets.FindByUuid(pset.Uuid)
- if found == nil {
- log.Info("new patchset", pset.Name, pset.Uuid)
- pset.State = "new"
- foundnew = true
- } else {
- log.Info("patchset already on disk", found.Name, found.State)
- pset.State = found.State
- if pset.State == "" {
- pset.State = "new"
- }
- }
- }
- dwin.doPatchsetsTable(psets)
- if foundnew {
- log.Info("should save these here")
- me.psets = psets
- savePatchsets()
- }
+ loadUpstreamPatchsets()
+ dwin.doPatchsetsTable(me.psets)
})
grid.NewButton("save", func() {
@@ -354,7 +358,12 @@ func setNewCommitHash(p *forgepb.Patchset) bool {
func AddNotDonePatches(notdone *forgepb.Patches, pset *forgepb.Patchset) {
for patch := range pset.Patches.IterAll() {
- // parts := strings.Fields(patch.Comment)
+ comment := cleanSubject(patch.Comment)
+
+ if found := notdone.FindByCommitHash(patch.CommitHash); found != nil {
+ log.Info("duplicate notdone patch:", patch.NewHash, "commithash:", patch.CommitHash, patch.RepoNamespace, comment)
+ continue
+ }
repo := me.forge.FindByGoPath(patch.RepoNamespace)
if repo == nil {
@@ -363,8 +372,6 @@ func AddNotDonePatches(notdone *forgepb.Patches, pset *forgepb.Patchset) {
continue
}
- comment := cleanSubject(patch.Comment)
-
if patch.NewHash != "na" {
log.Info("already applied patch: newhash:", patch.NewHash, "commithash:", patch.CommitHash, patch.RepoNamespace, comment)
continue
@@ -379,6 +386,6 @@ func AddNotDonePatches(notdone *forgepb.Patches, pset *forgepb.Patchset) {
// this patch has not been applied yet
log.Info("patch: not found hash:", patch.CommitHash, patch.RepoNamespace, comment, newhash, err)
- notdone.Append(patch)
+ notdone.AppendByCommitHash(patch) // double check to ensure the commit hash isn't added twice
}
}