window with only unapplied patches
This commit is contained in:
parent
edc362f4b9
commit
aed4c92713
40
doGui.go
40
doGui.go
|
@ -193,19 +193,6 @@ func drawWindow(win *gadgets.GenericWindow) {
|
||||||
releaseWin = makeModeMasterWin()
|
releaseWin = makeModeMasterWin()
|
||||||
})
|
})
|
||||||
|
|
||||||
/*
|
|
||||||
// the Devel / Patch mode window
|
|
||||||
var patchWin *patchesWindow
|
|
||||||
gridM.NewButton("Patch Window", func() {
|
|
||||||
if patchWin != nil {
|
|
||||||
patchWin.Toggle()
|
|
||||||
return
|
|
||||||
}
|
|
||||||
patchWin = new(patchesWindow)
|
|
||||||
patchWin.initWindow()
|
|
||||||
patchWin.Show()
|
|
||||||
})
|
|
||||||
*/
|
|
||||||
var patches *stdPatchsetTableWin
|
var patches *stdPatchsetTableWin
|
||||||
gridM.NewButton("Patch Window", func() {
|
gridM.NewButton("Patch Window", func() {
|
||||||
if patches != nil {
|
if patches != nil {
|
||||||
|
@ -234,6 +221,33 @@ func drawWindow(win *gadgets.GenericWindow) {
|
||||||
reposWin = makeReposWin()
|
reposWin = makeReposWin()
|
||||||
})
|
})
|
||||||
|
|
||||||
|
var patchesWin *stdPatchTableWin
|
||||||
|
gridM.NewButton("Pending patches", func() {
|
||||||
|
if patchesWin != nil {
|
||||||
|
patchesWin.Toggle()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
loadUpstreamPatchsets()
|
||||||
|
if me.psets == nil {
|
||||||
|
log.Info("failed to download current patchsets")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
notdone := new(forgepb.Patches)
|
||||||
|
|
||||||
|
all := me.psets.All()
|
||||||
|
for all.Scan() {
|
||||||
|
pset := all.Next()
|
||||||
|
AddNotDonePatches(notdone, pset)
|
||||||
|
}
|
||||||
|
|
||||||
|
for patch := range notdone.IterAll() {
|
||||||
|
comment := cleanSubject(patch.Comment)
|
||||||
|
log.Info("new patch:", patch.NewHash, "commithash:", patch.CommitHash, patch.RepoNamespace, comment)
|
||||||
|
}
|
||||||
|
// savePatchsets()
|
||||||
|
patchesWin = makePatchesWin(notdone)
|
||||||
|
})
|
||||||
|
|
||||||
// set the initial button state based on the last
|
// set the initial button state based on the last
|
||||||
// forge mode the user saved in the config file
|
// forge mode the user saved in the config file
|
||||||
switch me.forge.Config.Mode {
|
switch me.forge.Config.Mode {
|
||||||
|
|
|
@ -36,6 +36,37 @@ func (w *stdPatchsetTableWin) Toggle() {
|
||||||
w.win.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 {
|
func makePatchsetsWin() *stdPatchsetTableWin {
|
||||||
dwin := new(stdPatchsetTableWin)
|
dwin := new(stdPatchsetTableWin)
|
||||||
dwin.win = gadgets.NewGenericWindow("forge current patchsets", "patchset options")
|
dwin.win = gadgets.NewGenericWindow("forge current patchsets", "patchset options")
|
||||||
|
@ -54,35 +85,8 @@ func makePatchsetsWin() *stdPatchsetTableWin {
|
||||||
})
|
})
|
||||||
|
|
||||||
grid.NewButton("upstream", func() {
|
grid.NewButton("upstream", func() {
|
||||||
psets, err := me.forge.GetPatchesets()
|
loadUpstreamPatchsets()
|
||||||
if err != nil {
|
dwin.doPatchsetsTable(me.psets)
|
||||||
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()
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
|
|
||||||
grid.NewButton("save", func() {
|
grid.NewButton("save", func() {
|
||||||
|
@ -354,7 +358,12 @@ func setNewCommitHash(p *forgepb.Patchset) bool {
|
||||||
|
|
||||||
func AddNotDonePatches(notdone *forgepb.Patches, pset *forgepb.Patchset) {
|
func AddNotDonePatches(notdone *forgepb.Patches, pset *forgepb.Patchset) {
|
||||||
for patch := range pset.Patches.IterAll() {
|
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)
|
repo := me.forge.FindByGoPath(patch.RepoNamespace)
|
||||||
if repo == nil {
|
if repo == nil {
|
||||||
|
@ -363,8 +372,6 @@ func AddNotDonePatches(notdone *forgepb.Patches, pset *forgepb.Patchset) {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
comment := cleanSubject(patch.Comment)
|
|
||||||
|
|
||||||
if patch.NewHash != "na" {
|
if patch.NewHash != "na" {
|
||||||
log.Info("already applied patch: newhash:", patch.NewHash, "commithash:", patch.CommitHash, patch.RepoNamespace, comment)
|
log.Info("already applied patch: newhash:", patch.NewHash, "commithash:", patch.CommitHash, patch.RepoNamespace, comment)
|
||||||
continue
|
continue
|
||||||
|
@ -379,6 +386,6 @@ func AddNotDonePatches(notdone *forgepb.Patches, pset *forgepb.Patchset) {
|
||||||
|
|
||||||
// this patch has not been applied yet
|
// this patch has not been applied yet
|
||||||
log.Info("patch: not found hash:", patch.CommitHash, patch.RepoNamespace, comment, newhash, err)
|
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
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue