more code and gui cleanups
This commit is contained in:
parent
441c1e7ad8
commit
5d4850a93d
173
windowPatches.go
173
windowPatches.go
|
@ -1,9 +1,12 @@
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
|
"strconv"
|
||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
"go.wit.com/lib/gadgets"
|
"go.wit.com/lib/gadgets"
|
||||||
|
"go.wit.com/lib/protobuf/forgepb"
|
||||||
"go.wit.com/log"
|
"go.wit.com/log"
|
||||||
|
|
||||||
"go.wit.com/gui"
|
"go.wit.com/gui"
|
||||||
|
@ -77,63 +80,161 @@ func (r *patchesWindow) initWindow() {
|
||||||
// update the stats about the repos and patches
|
// update the stats about the repos and patches
|
||||||
r.summary.Update()
|
r.summary.Update()
|
||||||
|
|
||||||
g := r.stack.NewGroup("PatchSet List")
|
g := r.stack.NewGroup("Patchset List")
|
||||||
|
|
||||||
// add the grid
|
// add the grid
|
||||||
r.setgrid = g.NewGrid("", 0, 0)
|
r.setgrid = g.NewGrid("", 0, 0)
|
||||||
/*
|
}
|
||||||
r.setlist = make(map[string]*forgepb.Patchset)
|
|
||||||
r.setwin = make(map[string]*patchWindow)
|
|
||||||
|
|
||||||
// query for current patchsets
|
type patchSummary struct {
|
||||||
lines, err := listPatches()
|
grid *gui.Node
|
||||||
|
updateB *gui.Node
|
||||||
|
docsB *gui.Node
|
||||||
|
gitPushB *gui.Node
|
||||||
|
gitPullB *gui.Node
|
||||||
|
checkB *gui.Node
|
||||||
|
totalOL *gadgets.OneLiner
|
||||||
|
dirtyOL *gadgets.OneLiner
|
||||||
|
readonlyOL *gadgets.OneLiner
|
||||||
|
rw *gadgets.OneLiner
|
||||||
|
totalPatchesOL *gadgets.OneLiner
|
||||||
|
totalUserRepos *gui.Node
|
||||||
|
totalDevelRepos *gui.Node
|
||||||
|
totalMasterRepos *gui.Node
|
||||||
|
// totalUserPatches *gui.Node
|
||||||
|
totalDevelPatches *gui.Node
|
||||||
|
totalMasterPatches *gui.Node
|
||||||
|
// fileCount *gui.Node
|
||||||
|
unknownOL *gadgets.BasicEntry
|
||||||
|
unknownSubmitB *gui.Node
|
||||||
|
reason *gadgets.BasicEntry
|
||||||
|
submitB *gui.Node
|
||||||
|
// allp []*repolist.Patch
|
||||||
|
}
|
||||||
|
|
||||||
|
func (r *patchesWindow) submitPatchesBox(box *gui.Node) *patchSummary {
|
||||||
|
s := new(patchSummary)
|
||||||
|
group1 := box.NewGroup("Repo Summary")
|
||||||
|
s.grid = group1.RawGrid()
|
||||||
|
|
||||||
|
s.totalOL = gadgets.NewOneLiner(s.grid, "Total")
|
||||||
|
// _ = s.grid.NewLabel("total changes")
|
||||||
|
// _ = s.grid.NewLabel("user to devel")
|
||||||
|
s.grid.NextRow()
|
||||||
|
|
||||||
|
s.dirtyOL = gadgets.NewOneLiner(s.grid, "dirty")
|
||||||
|
_ = s.grid.NewLabel("") // skip a column
|
||||||
|
s.totalUserRepos = s.grid.NewLabel("x go repos")
|
||||||
|
s.grid.NextRow()
|
||||||
|
|
||||||
|
s.readonlyOL = gadgets.NewOneLiner(s.grid, "read-only")
|
||||||
|
_ = s.grid.NewLabel("") // skip a column
|
||||||
|
// s.totalUserPatches = s.grid.NewLabel("x patches")
|
||||||
|
s.grid.NextRow()
|
||||||
|
|
||||||
|
s.rw = gadgets.NewOneLiner(s.grid, "r/w")
|
||||||
|
_ = s.grid.NewLabel("") // skip a column
|
||||||
|
// s.fileCount = s.grid.NewLabel("x files")
|
||||||
|
s.grid.NextRow()
|
||||||
|
|
||||||
|
group1 = box.NewGroup("Patchset Create")
|
||||||
|
s.grid = group1.RawGrid()
|
||||||
|
|
||||||
|
s.grid.NewButton("current patch summary", func() {
|
||||||
|
s.Update()
|
||||||
|
pset, err := me.forge.MakeDevelPatchSet("current patches")
|
||||||
|
if err != nil {
|
||||||
|
log.Info("patchset creation failed", err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if pset == nil {
|
||||||
|
log.Info("you have no current patches")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
win := makePatchWindow(pset)
|
||||||
|
win.Show()
|
||||||
|
})
|
||||||
|
|
||||||
|
s.reason = gadgets.NewBasicEntry(s.grid, "Patchset name:")
|
||||||
|
s.reason.Custom = func() {
|
||||||
|
if s.reason.String() != "" {
|
||||||
|
s.submitB.Enable()
|
||||||
|
} else {
|
||||||
|
s.submitB.Disable()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
s.submitB = s.grid.NewButton("Submit", func() {
|
||||||
|
pset, err := me.forge.SubmitDevelPatchSet(s.reason.String())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Info(err)
|
log.Info(err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
slices.Reverse(lines)
|
// line := "somedate " + s.reason.String() + " Author: me" + pset.GitAuthorEmail
|
||||||
count := 0
|
r.addPatchsetNew(pset)
|
||||||
for i, line := range lines {
|
})
|
||||||
log.Info(i, line)
|
s.grid.NewButton("Get Patchsets", func() {
|
||||||
count += 1
|
if psets, err := me.forge.GetPatchesets(); err != nil {
|
||||||
if count < 10 {
|
log.Info("Get Patchsets failed", err)
|
||||||
r.addPatchset(line)
|
return
|
||||||
|
} else {
|
||||||
|
log.Info("got psets len", len(psets.Patchsets))
|
||||||
|
// all := psets.All()
|
||||||
|
all := psets.SortByName()
|
||||||
|
for all.Scan() {
|
||||||
|
pset := all.Next()
|
||||||
|
r.addPatchsetNew(pset)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
log.Info("Total patchsets:", count)
|
})
|
||||||
*/
|
|
||||||
|
s.submitB.Disable()
|
||||||
|
s.grid.NextRow()
|
||||||
|
return s
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
func (r *patchesWindow) addPatchsetNew(pset *forgepb.Patchset) {
|
||||||
func (r *patchesWindow) addPatchset(line string) {
|
r.setgrid.NewLabel(pset.Name)
|
||||||
parts := strings.Split(line, "Author:")
|
r.setgrid.NewLabel(pset.Comment)
|
||||||
author := parts[1]
|
r.setgrid.NewLabel(pset.GitAuthorName)
|
||||||
parts = strings.Fields(parts[0])
|
|
||||||
name := parts[0]
|
|
||||||
subject := strings.Join(parts[1:], " ")
|
|
||||||
r.setgrid.NewLabel(name)
|
|
||||||
r.setgrid.NewLabel(subject)
|
|
||||||
r.setgrid.NewLabel(author)
|
|
||||||
|
|
||||||
|
var win *patchWindow
|
||||||
r.setgrid.NewButton("View", func() {
|
r.setgrid.NewButton("View", func() {
|
||||||
// has the window already been created?
|
// has the window already been created?
|
||||||
win := r.setwin[name]
|
|
||||||
if win != nil {
|
if win != nil {
|
||||||
|
// it has been already created. just show it
|
||||||
win.Toggle()
|
win.Toggle()
|
||||||
log.Info("TRYING TO TOGGLE WINDOW")
|
log.Info("TRYING TO TOGGLE WINDOW")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// get the patch and make the window
|
win = makePatchWindow(pset)
|
||||||
pset, err := getPatch(name)
|
win.Show()
|
||||||
if err != nil {
|
|
||||||
log.Info(name, "failed to download", err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
r.setlist[name] = pset
|
|
||||||
r.setwin[name] = makePatchWindow(pset)
|
|
||||||
r.setwin[name].Show()
|
|
||||||
})
|
})
|
||||||
r.setgrid.NextRow()
|
r.setgrid.NextRow()
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
|
// does not run any commands
|
||||||
|
func (s *patchSummary) Update() {
|
||||||
|
var total, dirty, readonly, rw int
|
||||||
|
var userT int // , develT, masterT int
|
||||||
|
// var userP, develP, masterP int
|
||||||
|
// broken after move to forge protobuf
|
||||||
|
all := me.forge.Repos.SortByFullPath()
|
||||||
|
for all.Scan() {
|
||||||
|
repo := all.Next()
|
||||||
|
total += 1
|
||||||
|
if repo.IsDirty() {
|
||||||
|
dirty += 1
|
||||||
|
}
|
||||||
|
if me.forge.Config.IsReadOnly(repo.GetGoPath()) {
|
||||||
|
readonly += 1
|
||||||
|
} else {
|
||||||
|
rw += 1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
s.totalOL.SetText(strconv.Itoa(total) + " repos")
|
||||||
|
s.dirtyOL.SetText(strconv.Itoa(dirty) + " repos")
|
||||||
|
s.readonlyOL.SetText(strconv.Itoa(readonly) + " repos")
|
||||||
|
s.rw.SetText(fmt.Sprintf("%d repos", rw))
|
||||||
|
s.totalUserRepos.SetText(strconv.Itoa(userT) + " repos")
|
||||||
|
}
|
||||||
|
|
|
@ -1,166 +0,0 @@
|
||||||
package main
|
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
"strconv"
|
|
||||||
|
|
||||||
"go.wit.com/gui"
|
|
||||||
"go.wit.com/lib/gadgets"
|
|
||||||
"go.wit.com/lib/protobuf/forgepb"
|
|
||||||
"go.wit.com/log"
|
|
||||||
)
|
|
||||||
|
|
||||||
type patchSummary struct {
|
|
||||||
grid *gui.Node
|
|
||||||
updateB *gui.Node
|
|
||||||
docsB *gui.Node
|
|
||||||
gitPushB *gui.Node
|
|
||||||
gitPullB *gui.Node
|
|
||||||
checkB *gui.Node
|
|
||||||
totalOL *gadgets.OneLiner
|
|
||||||
dirtyOL *gadgets.OneLiner
|
|
||||||
readonlyOL *gadgets.OneLiner
|
|
||||||
rw *gadgets.OneLiner
|
|
||||||
totalPatchesOL *gadgets.OneLiner
|
|
||||||
totalUserRepos *gui.Node
|
|
||||||
totalDevelRepos *gui.Node
|
|
||||||
totalMasterRepos *gui.Node
|
|
||||||
totalUserPatches *gui.Node
|
|
||||||
totalDevelPatches *gui.Node
|
|
||||||
totalMasterPatches *gui.Node
|
|
||||||
fileCount *gui.Node
|
|
||||||
unknownOL *gadgets.BasicEntry
|
|
||||||
unknownSubmitB *gui.Node
|
|
||||||
reason *gadgets.BasicEntry
|
|
||||||
submitB *gui.Node
|
|
||||||
// allp []*repolist.Patch
|
|
||||||
}
|
|
||||||
|
|
||||||
func (r *patchesWindow) submitPatchesBox(box *gui.Node) *patchSummary {
|
|
||||||
s := new(patchSummary)
|
|
||||||
group1 := box.NewGroup("Patch Summary")
|
|
||||||
s.grid = group1.RawGrid()
|
|
||||||
|
|
||||||
s.totalOL = gadgets.NewOneLiner(s.grid, "Total")
|
|
||||||
_ = s.grid.NewLabel("total changes")
|
|
||||||
_ = s.grid.NewLabel("user to devel")
|
|
||||||
s.grid.NextRow()
|
|
||||||
|
|
||||||
s.dirtyOL = gadgets.NewOneLiner(s.grid, "dirty")
|
|
||||||
_ = s.grid.NewLabel("") // skip a column
|
|
||||||
s.totalUserRepos = s.grid.NewLabel("x go repos")
|
|
||||||
s.grid.NextRow()
|
|
||||||
|
|
||||||
s.readonlyOL = gadgets.NewOneLiner(s.grid, "read-only")
|
|
||||||
_ = s.grid.NewLabel("") // skip a column
|
|
||||||
s.totalUserPatches = s.grid.NewLabel("x patches")
|
|
||||||
s.grid.NextRow()
|
|
||||||
|
|
||||||
s.rw = gadgets.NewOneLiner(s.grid, "r/w")
|
|
||||||
_ = s.grid.NewLabel("") // skip a column
|
|
||||||
s.fileCount = s.grid.NewLabel("x files")
|
|
||||||
s.grid.NextRow()
|
|
||||||
|
|
||||||
group1 = box.NewGroup("PatchSet Create")
|
|
||||||
s.grid = group1.RawGrid()
|
|
||||||
|
|
||||||
s.grid.NewButton("update patch summary", func() {
|
|
||||||
s.Update()
|
|
||||||
pset, err := me.forge.MakeDevelPatchSet("current patches")
|
|
||||||
if err != nil {
|
|
||||||
log.Info("patchset creation failed", err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if pset == nil {
|
|
||||||
log.Info("you have no current patches")
|
|
||||||
return
|
|
||||||
}
|
|
||||||
win := makePatchWindow(pset)
|
|
||||||
win.Show()
|
|
||||||
})
|
|
||||||
|
|
||||||
s.reason = gadgets.NewBasicEntry(s.grid, "Patchset name:")
|
|
||||||
s.reason.Custom = func() {
|
|
||||||
if s.reason.String() != "" {
|
|
||||||
s.submitB.Enable()
|
|
||||||
} else {
|
|
||||||
s.submitB.Disable()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
s.submitB = s.grid.NewButton("Submit", func() {
|
|
||||||
pset, err := me.forge.SubmitDevelPatchSet(s.reason.String())
|
|
||||||
if err != nil {
|
|
||||||
log.Info(err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
// line := "somedate " + s.reason.String() + " Author: me" + pset.GitAuthorEmail
|
|
||||||
r.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
|
|
||||||
// s.reason.Disable()
|
|
||||||
s.submitB.Disable()
|
|
||||||
s.grid.NextRow()
|
|
||||||
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
|
|
||||||
var userT int // , develT, masterT int
|
|
||||||
// var userP, develP, masterP int
|
|
||||||
// broken after move to forge protobuf
|
|
||||||
all := me.forge.Repos.SortByFullPath()
|
|
||||||
for all.Scan() {
|
|
||||||
repo := all.Next()
|
|
||||||
total += 1
|
|
||||||
if repo.IsDirty() {
|
|
||||||
dirty += 1
|
|
||||||
}
|
|
||||||
if me.forge.Config.IsReadOnly(repo.GetGoPath()) {
|
|
||||||
readonly += 1
|
|
||||||
} else {
|
|
||||||
rw += 1
|
|
||||||
}
|
|
||||||
}
|
|
||||||
s.totalOL.SetText(strconv.Itoa(total) + " repos")
|
|
||||||
s.dirtyOL.SetText(strconv.Itoa(dirty) + " repos")
|
|
||||||
s.readonlyOL.SetText(strconv.Itoa(readonly) + " repos")
|
|
||||||
s.rw.SetText(fmt.Sprintf("%d repos", rw))
|
|
||||||
|
|
||||||
s.totalUserRepos.SetText(strconv.Itoa(userT) + " repos")
|
|
||||||
}
|
|
|
@ -78,11 +78,6 @@ func makeRepoPatchWindow(repo *gitpb.Repo, fset []*forgepb.Patch) *repoPatchWind
|
||||||
grid.NewLabel(repo.GetGoPath())
|
grid.NewLabel(repo.GetGoPath())
|
||||||
grid.NewLabel(repo.GetCurrentBranchName())
|
grid.NewLabel(repo.GetCurrentBranchName())
|
||||||
|
|
||||||
grid.NewButton("Apply all with git am", func() {
|
|
||||||
})
|
|
||||||
grid.NewButton("Squash", func() {
|
|
||||||
})
|
|
||||||
|
|
||||||
g := pw.stack.NewGroup("PatchSet List")
|
g := pw.stack.NewGroup("PatchSet List")
|
||||||
|
|
||||||
// make a grid and a header
|
// make a grid and a header
|
||||||
|
@ -91,6 +86,10 @@ func makeRepoPatchWindow(repo *gitpb.Repo, fset []*forgepb.Patch) *repoPatchWind
|
||||||
filegrid.NewLabel("Applied in current branch?")
|
filegrid.NewLabel("Applied in current branch?")
|
||||||
filegrid.NewLabel("original hash")
|
filegrid.NewLabel("original hash")
|
||||||
filegrid.NewLabel("new hash")
|
filegrid.NewLabel("new hash")
|
||||||
|
filegrid.NewButton("git squash", func() {
|
||||||
|
})
|
||||||
|
filegrid.NewButton("git am", func() {
|
||||||
|
})
|
||||||
filegrid.NextRow()
|
filegrid.NextRow()
|
||||||
|
|
||||||
for _, p := range fset {
|
for _, p := range fset {
|
||||||
|
@ -98,6 +97,8 @@ func makeRepoPatchWindow(repo *gitpb.Repo, fset []*forgepb.Patch) *repoPatchWind
|
||||||
filegrid.NewLabel("yes?")
|
filegrid.NewLabel("yes?")
|
||||||
filegrid.NewLabel(p.CommitHash)
|
filegrid.NewLabel(p.CommitHash)
|
||||||
filegrid.NewLabel(p.NewHash)
|
filegrid.NewLabel(p.NewHash)
|
||||||
|
filegrid.NewCheckbox("").SetChecked(true)
|
||||||
|
filegrid.NewCheckbox("").SetChecked(true)
|
||||||
filegrid.NextRow()
|
filegrid.NextRow()
|
||||||
}
|
}
|
||||||
// add the patches to the grid
|
// add the patches to the grid
|
||||||
|
|
Loading…
Reference in New Issue