GetPatchsets work
This commit is contained in:
parent
a76028dd23
commit
e7d71c78e2
4
main.go
4
main.go
|
@ -54,6 +54,10 @@ func main() {
|
|||
if me.urlbase == "" {
|
||||
me.urlbase = "https://go.wit.com/"
|
||||
}
|
||||
if os.Getenv("FORGE_URL") != "" {
|
||||
me.urlbase = os.Getenv("FORGE_URL")
|
||||
log.Info("got forge url", me.urlbase)
|
||||
}
|
||||
me.urlbase = strings.Trim(me.urlbase, "/") // track down why trailing '/' makes http POST not work
|
||||
|
||||
// load the ~/.config/forge/ config
|
||||
|
|
|
@ -1,27 +1,24 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"slices"
|
||||
"strings"
|
||||
"sync"
|
||||
|
||||
"go.wit.com/lib/gadgets"
|
||||
"go.wit.com/lib/protobuf/forgepb"
|
||||
"go.wit.com/log"
|
||||
|
||||
"go.wit.com/gui"
|
||||
)
|
||||
|
||||
type patchesWindow struct {
|
||||
once sync.Once // only init() the window once
|
||||
win *gadgets.BasicWindow // the patches window
|
||||
stack *gui.Node // the top box set as vertical
|
||||
shelf *gui.Node // the first box in the stack, set as horizontal
|
||||
grid *gui.Node // the list of available patches
|
||||
summary *patchSummary // summary of current patches
|
||||
setgrid *gui.Node // the list of each patchset
|
||||
setlist map[string]*forgepb.Patchset // a map of the patch names to the protobuf
|
||||
setwin map[string]*patchWindow // a map of the patch names to the protobuf
|
||||
once sync.Once // only init() the window once
|
||||
win *gadgets.BasicWindow // the patches window
|
||||
stack *gui.Node // the top box set as vertical
|
||||
shelf *gui.Node // the first box in the stack, set as horizontal
|
||||
grid *gui.Node // the list of available patches
|
||||
summary *patchSummary // summary of current patches
|
||||
setgrid *gui.Node // the list of each patchset
|
||||
// setlist map[string]*forgepb.Patchset // a map of the patch names to the protobuf
|
||||
// setwin map[string]*patchWindow // a map of the patch names to the protobuf
|
||||
}
|
||||
|
||||
func (r *patchesWindow) Hidden() bool {
|
||||
|
@ -84,27 +81,30 @@ func (r *patchesWindow) initWindow() {
|
|||
|
||||
// add the grid
|
||||
r.setgrid = g.NewGrid("", 0, 0)
|
||||
r.setlist = make(map[string]*forgepb.Patchset)
|
||||
r.setwin = make(map[string]*patchWindow)
|
||||
/*
|
||||
r.setlist = make(map[string]*forgepb.Patchset)
|
||||
r.setwin = make(map[string]*patchWindow)
|
||||
|
||||
// query for current patchsets
|
||||
lines, err := listPatches()
|
||||
if err != nil {
|
||||
log.Info(err)
|
||||
return
|
||||
}
|
||||
slices.Reverse(lines)
|
||||
count := 0
|
||||
for i, line := range lines {
|
||||
log.Info(i, line)
|
||||
count += 1
|
||||
if count < 10 {
|
||||
r.addPatchset(line)
|
||||
// query for current patchsets
|
||||
lines, err := listPatches()
|
||||
if err != nil {
|
||||
log.Info(err)
|
||||
return
|
||||
}
|
||||
}
|
||||
log.Info("Total patchsets:", count)
|
||||
slices.Reverse(lines)
|
||||
count := 0
|
||||
for i, line := range lines {
|
||||
log.Info(i, line)
|
||||
count += 1
|
||||
if count < 10 {
|
||||
r.addPatchset(line)
|
||||
}
|
||||
}
|
||||
log.Info("Total patchsets:", count)
|
||||
*/
|
||||
}
|
||||
|
||||
/*
|
||||
func (r *patchesWindow) addPatchset(line string) {
|
||||
parts := strings.Split(line, "Author:")
|
||||
author := parts[1]
|
||||
|
@ -136,3 +136,4 @@ func (r *patchesWindow) addPatchset(line string) {
|
|||
})
|
||||
r.setgrid.NextRow()
|
||||
}
|
||||
*/
|
||||
|
|
|
@ -6,6 +6,7 @@ import (
|
|||
|
||||
"go.wit.com/gui"
|
||||
"go.wit.com/lib/gadgets"
|
||||
"go.wit.com/lib/protobuf/forgepb"
|
||||
"go.wit.com/log"
|
||||
)
|
||||
|
||||
|
@ -81,8 +82,21 @@ func (r *patchesWindow) submitPatchesBox(box *gui.Node) *patchSummary {
|
|||
log.Info(err)
|
||||
return
|
||||
}
|
||||
line := "somedate " + s.reason.String() + " Author: me" + pset.GitAuthorEmail
|
||||
me.patchWin.addPatchset(line)
|
||||
// line := "somedate " + s.reason.String() + " Author: me" + pset.GitAuthorEmail
|
||||
me.patchWin.addPatchsetNew(pset)
|
||||
})
|
||||
s.grid.NewButton("Get Patchsets", func() {
|
||||
if psets, err := me.forge.GetPatchesets(); err != nil {
|
||||
log.Info("Get Patchsets failed", err)
|
||||
return
|
||||
} else {
|
||||
log.Info("got psets len", len(psets.Patchsets))
|
||||
all := psets.All()
|
||||
for all.Scan() {
|
||||
pset := all.Next()
|
||||
r.addPatchsetNew(pset)
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
// disable these until there are not dirty repos
|
||||
|
@ -92,6 +106,27 @@ func (r *patchesWindow) submitPatchesBox(box *gui.Node) *patchSummary {
|
|||
return s
|
||||
}
|
||||
|
||||
func (r *patchesWindow) addPatchsetNew(pset *forgepb.Patchset) {
|
||||
r.setgrid.NewLabel(pset.Name)
|
||||
r.setgrid.NewLabel(pset.Comment)
|
||||
r.setgrid.NewLabel(pset.GitAuthorName)
|
||||
|
||||
var win *patchWindow
|
||||
r.setgrid.NewButton("View", func() {
|
||||
// has the window already been created?
|
||||
if win != nil {
|
||||
// it has been already created. just show it
|
||||
win.Toggle()
|
||||
log.Info("TRYING TO TOGGLE WINDOW")
|
||||
return
|
||||
}
|
||||
|
||||
win = makePatchWindow(pset)
|
||||
win.Show()
|
||||
})
|
||||
r.setgrid.NextRow()
|
||||
}
|
||||
|
||||
// does not run any commands
|
||||
func (s *patchSummary) Update() {
|
||||
var total, dirty, readonly, rw int
|
||||
|
|
|
@ -132,7 +132,7 @@ func (r *patchWindow) addPatchset(grid *gui.Node, pset *forgepb.Patchset) {
|
|||
s := p.RepoNamespace
|
||||
repo := me.forge.FindByGoPath(s)
|
||||
if repo == nil {
|
||||
log.Info("COULD NOT FIND", s)
|
||||
log.Info("Could not figure out repo path", s)
|
||||
continue
|
||||
}
|
||||
repomap[repo] = append(repomap[repo], p)
|
||||
|
|
Loading…
Reference in New Issue