working on more standard patch windows

This commit is contained in:
Jeff Carr 2025-03-10 14:57:33 -05:00
parent 18d9a7a099
commit 391a988e5f
4 changed files with 55 additions and 105 deletions

View File

@ -11,7 +11,6 @@ import (
"strconv"
"go.wit.com/lib/gadgets"
"go.wit.com/lib/protobuf/forgepb"
"go.wit.com/log"
"go.wit.com/gui"
@ -102,8 +101,10 @@ func (r *patchesWindow) submitPatchesBox() {
log.Info("you have no current patches")
return
}
win := makePatchWindow(pset)
win.Show()
/*
win := makePatchWindow(pset)
win.Show()
*/
})
r.reason = gadgets.NewBasicEntry(grid, "Patchset name:")
@ -123,12 +124,12 @@ func (r *patchesWindow) submitPatchesBox() {
log.Info("submit button is disabled. BAD GUI TOOLKIT ERROR")
return
}
pset, err := me.forge.SubmitDevelPatchSet(r.reason.String())
if err != nil {
log.Info(err)
return
}
r.addPatchsetNew(pset)
// pset, err := me.forge.SubmitDevelPatchSet(r.reason.String())
// if err != nil {
// log.Info(err)
// return
// }
// r.addPatchsetNew(pset)
})
psets, err := openPatchsets()
@ -144,12 +145,14 @@ func (r *patchesWindow) submitPatchesBox() {
}
savePatchsets(psets)
log.Info("got psets len", len(psets.Patchsets))
all := psets.SortByName()
for all.Scan() {
pset := all.Next()
r.addPatchsetNew(pset)
}
/*
log.Info("got psets len", len(psets.Patchsets))
all := psets.SortByName()
for all.Scan() {
pset := all.Next()
r.addPatchsetNew(pset)
}
*/
})
// disables the submit button until the user enters a name
@ -165,15 +168,18 @@ func (r *patchesWindow) submitPatchesBox() {
if psets != nil {
log.Info("got psets len", len(psets.Patchsets))
all := psets.SortByName()
for all.Scan() {
pset := all.Next()
// log.Info("pset name =", pset.Name)
r.addPatchsetNew(pset)
}
/*
all := psets.SortByName()
for all.Scan() {
pset := all.Next()
log.Info("pset name =", pset.Name)
r.addPatchsetNew(pset)
}
*/
}
}
/*
func (r *patchesWindow) addPatchsetNew(pset *forgepb.Patchset) {
var win *patchWindow
r.psetgrid.NewButton("View", func() {
@ -183,8 +189,8 @@ func (r *patchesWindow) addPatchsetNew(pset *forgepb.Patchset) {
return
}
win = makePatchWindow(pset)
win.Show()
// win = makePatchWindow(pset)
// win.Show()
})
r.psetgrid.NewLabel(pset.Name)
r.psetgrid.NewLabel(pset.Comment)
@ -202,6 +208,7 @@ func (r *patchesWindow) addPatchsetNew(pset *forgepb.Patchset) {
r.psetgrid.NextRow()
}
*/
// will update this from the current state of the protobuf
func (r *patchesWindow) Update() {

View File

@ -32,9 +32,10 @@ func (w *stdPatchTableWin) Toggle() {
func makePatchesWin() *stdPatchTableWin {
dwin := new(stdPatchTableWin)
dwin.win = gadgets.NewGenericWindow("forge current patchsets", "who is squirreling around?")
dwin.win = gadgets.NewGenericWindow("current patches", "patching options")
dwin.win.Custom = func() {
log.Info("test delete window here")
// dwin = nil
}
grid := dwin.win.Group.RawGrid()
@ -54,6 +55,13 @@ func (dwin *stdPatchTableWin) doPatchesTable(currentPatches *forgepb.Patches) {
dwin.TB.Delete()
dwin.TB = nil
}
// display the protobuf
dwin.TB = AddPatchesPB(dwin.box, currentPatches)
f := func(p *forgepb.Patch) {
log.Info("do something with patch", p.Filename)
}
dwin.TB.Custom(f)
}
// define what rows to have in the protobuf table

View File

@ -33,7 +33,7 @@ func (w *stdPatchsetTableWin) Toggle() {
func makePatchsetsWin() *stdPatchsetTableWin {
dwin := new(stdPatchsetTableWin)
dwin.win = gadgets.NewGenericWindow("forge current patchsets", "who is squirreling around?")
dwin.win = gadgets.NewGenericWindow("forge current patchsets", "patchset options")
dwin.win.Custom = func() {
log.Info("test delete window here")
}
@ -88,8 +88,10 @@ func (dwin *stdPatchsetTableWin) doPatchsetsTable(currentPatchsets *forgepb.Patc
dwin.TB = AddPatchsetsPB(dwin.box, currentPatchsets)
f := func(pset *forgepb.Patchset) {
log.Info("Triggered. do something here", pset.Name)
win := makePatchWindow(pset)
win.Show()
/*
win := makePatchWindow(pset)
win.Show()
*/
}
dwin.TB.Custom(f)
}
@ -106,19 +108,22 @@ func AddPatchsetsPB(tbox *gui.Node, pb *forgepb.Patchsets) *forgepb.PatchsetsTab
testf := func(p *forgepb.Patchset) string {
return "test"
}
tp := t.AddButtonFunc("Analyse", testf)
tp := t.AddButtonFunc("Analyze", testf)
tp.Custom = func(p *forgepb.Patchset) {
log.Info("show patches here", p.Name)
patchwin := makePatchesWin()
patchwin.doPatchesTable(p.Patches)
log.Info("analyze patches here", p.Name)
}
vp := t.AddButtonFunc("View Patchset", func(p *forgepb.Patchset) string {
return p.Name
})
vp.Custom = func(pset *forgepb.Patchset) {
win := makePatchWindow(pset)
win.Show()
log.Info("show patches here", pset.Name)
patchwin := makePatchesWin()
patchwin.doPatchesTable(pset.Patches)
/*
win := makePatchWindow(pset)
win.Show()
*/
}
t.AddComment()

View File

@ -3,19 +3,7 @@
package main
import (
"os"
"path/filepath"
"sync"
"go.wit.com/lib/gadgets"
"go.wit.com/lib/protobuf/forgepb"
"go.wit.com/lib/protobuf/gitpb"
"go.wit.com/log"
"go.wit.com/gui"
)
/*
type patchWindow struct {
once sync.Once // only init() the window once
win *gadgets.BasicWindow // the patches window
@ -123,28 +111,6 @@ func makePatchWindow(pset *forgepb.Patchset) *patchWindow {
grid.NewLabel("Applied in current branch?")
grid.NewLabel("start hash")
grid.NewLabel("")
/*
grid.NewButton("Extract", func() {
if err := savePatchset(pset); err != nil {
log.Info("Save err:", err)
return
}
})
grid.NewButton("Apply with git am", func() {
if _, _, _, err := IsEverythingOnUser(); err != nil {
log.Info("You can only apply patches to the user branch")
return
}
if IsAnythingDirty() {
log.Info("You can't apply patches when repos are dirty")
me.forge.PrintHumanTable(me.found)
return
}
if argv.Force {
applyPatchset(pset)
}
})
*/
grid.NextRow()
// add the patches to the grid
@ -153,25 +119,6 @@ func makePatchWindow(pset *forgepb.Patchset) *patchWindow {
}
func (r *patchWindow) addPatchset(grid *gui.Node, pset *forgepb.Patchset) {
/*
repomap := make(map[*gitpb.Repo][]*forgepb.Patch)
repohash := make(map[*gitpb.Repo]string)
// sort patches by repo namespace
all := pset.Patches.SortByFilename()
for all.Scan() {
p := all.Next()
s := p.RepoNamespace
repo := me.forge.FindByGoPath(s)
if repo == nil {
log.Info("Could not figure out repo path", s)
continue
}
repomap[repo] = append(repomap[repo], p)
repohash[repo] = p.StartHash
}
*/
all := pset.Patches.SortByFilename()
for all.Scan() {
p := all.Next()
@ -185,14 +132,6 @@ func (r *patchWindow) addPatchset(grid *gui.Node, pset *forgepb.Patchset) {
log.Info("Adding patches for", rn)
grid.NewLabel(rn)
/*
for i, p := range patches {
log.Info(i, p.Filename)
grid.NewLabel(p.Comment)
grid.NewLabel("in current branch?")
break
}
*/
// hash := repohash[repo]
grid.NewLabel(p.StartHash)
grid.NewLabel(p.Filename)
@ -216,16 +155,6 @@ func (r *patchWindow) addPatchset(grid *gui.Node, pset *forgepb.Patchset) {
// for _, pat := range patches {
// }
})
/*
grid.NewButton("view hash", func() {
cmd := []string{"git", "whatchanged", hash}
log.Info(repo.GetFullPath(), cmd)
})
grid.NewButton("git am", func() {
cmd := []string{"git", "whatchanged", hash}
log.Info(repo.GetFullPath(), cmd)
})
*/
grid.NextRow()
}
}
@ -279,3 +208,4 @@ func savePatchset(pset *forgepb.Patchset) error {
}
return nil
}
*/