2024-02-12 15:24:35 -06:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
2024-02-13 21:18:33 -06:00
|
|
|
"path/filepath"
|
2024-02-13 12:54:32 -06:00
|
|
|
"strconv"
|
2024-02-12 15:24:35 -06:00
|
|
|
|
|
|
|
"go.wit.com/gui"
|
2024-02-13 12:54:32 -06:00
|
|
|
"go.wit.com/lib/gadgets"
|
2024-02-17 08:38:44 -06:00
|
|
|
"go.wit.com/lib/gui/repolist"
|
2024-02-13 21:18:33 -06:00
|
|
|
"go.wit.com/lib/gui/shell"
|
2024-02-12 15:24:35 -06:00
|
|
|
"go.wit.com/log"
|
|
|
|
)
|
|
|
|
|
2024-02-19 21:11:07 -06:00
|
|
|
/*
|
2024-02-13 16:18:37 -06:00
|
|
|
type patch struct {
|
|
|
|
ref string
|
|
|
|
giturl string
|
|
|
|
comment string
|
|
|
|
rs *repostatus.RepoStatus
|
|
|
|
}
|
2024-02-19 21:11:07 -06:00
|
|
|
*/
|
2024-02-13 16:18:37 -06:00
|
|
|
|
2024-02-13 13:50:19 -06:00
|
|
|
type patchSummary struct {
|
2024-02-13 20:29:14 -06:00
|
|
|
grid *gui.Node
|
|
|
|
updateB *gui.Node
|
|
|
|
docsB *gui.Node
|
|
|
|
gitPushB *gui.Node
|
|
|
|
gitPullB *gui.Node
|
|
|
|
checkB *gui.Node
|
2024-02-12 15:24:35 -06:00
|
|
|
|
2024-02-18 07:24:56 -06:00
|
|
|
// stats
|
|
|
|
totalOL *gadgets.OneLiner
|
|
|
|
totalGoOL *gadgets.OneLiner
|
|
|
|
dirtyOL *gadgets.OneLiner
|
|
|
|
readonlyOL *gadgets.OneLiner
|
|
|
|
totalPatchesOL *gadgets.OneLiner
|
|
|
|
totalUserRepos *gui.Node
|
|
|
|
totalDevelRepos *gui.Node
|
|
|
|
totalMasterRepos *gui.Node
|
|
|
|
totalUserPatches *gui.Node
|
|
|
|
totalDevelPatches *gui.Node
|
|
|
|
totalMasterPatches *gui.Node
|
2024-02-13 12:54:32 -06:00
|
|
|
|
2024-02-18 07:24:56 -06:00
|
|
|
// patch set generation
|
2024-02-20 14:44:12 -06:00
|
|
|
unknownOL *gadgets.BasicEntry
|
2024-02-13 16:18:37 -06:00
|
|
|
unknownSubmitB *gui.Node
|
2024-02-18 07:24:56 -06:00
|
|
|
reason *gadgets.BasicEntry
|
|
|
|
submitB *gui.Node
|
2024-02-19 21:11:07 -06:00
|
|
|
allp []*repolist.Patch
|
2024-02-13 12:54:32 -06:00
|
|
|
}
|
|
|
|
|
2024-02-13 13:50:19 -06:00
|
|
|
func submitPatchesBox(box *gui.Node) *patchSummary {
|
|
|
|
s := new(patchSummary)
|
2024-02-13 13:33:04 -06:00
|
|
|
group1 := box.NewGroup("Submit Patches Summary")
|
2024-02-13 12:54:32 -06:00
|
|
|
s.grid = group1.RawGrid()
|
|
|
|
|
2024-02-20 14:58:51 -06:00
|
|
|
s.grid.NewButton("Update Patch Counts", func() {
|
2024-02-20 10:58:58 -06:00
|
|
|
var repocount, patchcount int
|
2024-12-02 15:45:06 -06:00
|
|
|
// broken after move to forge protobuf
|
2024-12-11 19:32:04 -06:00
|
|
|
all := me.forge.Repos.SortByGoPath()
|
|
|
|
for all.Scan() {
|
|
|
|
repo := all.Next()
|
2024-12-02 15:45:06 -06:00
|
|
|
if repo.GetReadOnly() {
|
2024-02-20 10:58:58 -06:00
|
|
|
continue
|
|
|
|
}
|
|
|
|
i, _ := repo.GetMasterPatches()
|
|
|
|
patchcount += i
|
|
|
|
if i > 0 {
|
2024-02-20 06:52:43 -06:00
|
|
|
repocount += 1
|
2024-02-20 10:58:58 -06:00
|
|
|
}
|
2024-02-19 21:11:07 -06:00
|
|
|
}
|
2024-02-20 10:58:58 -06:00
|
|
|
s.totalMasterPatches.SetText(strconv.Itoa(patchcount) + " patches")
|
2024-02-20 06:52:43 -06:00
|
|
|
s.totalMasterRepos.SetText(strconv.Itoa(repocount) + " go repos")
|
2024-02-19 21:11:07 -06:00
|
|
|
|
2024-02-20 10:58:58 -06:00
|
|
|
repocount = 0
|
|
|
|
patchcount = 0
|
2024-12-02 15:45:06 -06:00
|
|
|
// broken after move to forge protobuf
|
2024-12-11 19:32:04 -06:00
|
|
|
all = me.forge.Repos.SortByGoPath()
|
|
|
|
for all.Scan() {
|
|
|
|
repo := all.Next()
|
2024-12-02 15:45:06 -06:00
|
|
|
if repo.GetReadOnly() {
|
2024-02-20 10:58:58 -06:00
|
|
|
continue
|
|
|
|
}
|
|
|
|
i, _ := repo.GetUserPatches()
|
|
|
|
patchcount += i
|
|
|
|
if i > 0 {
|
|
|
|
repocount += 1
|
2024-02-13 20:29:14 -06:00
|
|
|
}
|
|
|
|
}
|
2024-02-20 10:58:58 -06:00
|
|
|
s.totalUserPatches.SetText(strconv.Itoa(patchcount) + " patches")
|
|
|
|
s.totalUserRepos.SetText(strconv.Itoa(repocount) + " go repos")
|
2024-02-13 20:29:14 -06:00
|
|
|
})
|
|
|
|
|
2024-02-21 08:32:59 -06:00
|
|
|
/* this used to be the way and should probably be revisited
|
2024-02-20 14:58:51 -06:00
|
|
|
s.grid.NewButton("Make Patches", func() {
|
2024-02-20 10:58:58 -06:00
|
|
|
for i, p := range s.allp {
|
|
|
|
log.Info(i, p.Ref, p.RS.String())
|
2024-02-13 13:33:04 -06:00
|
|
|
}
|
2024-02-13 20:29:14 -06:00
|
|
|
})
|
2024-02-21 08:32:59 -06:00
|
|
|
*/
|
2024-02-13 20:29:14 -06:00
|
|
|
|
2024-02-18 07:24:56 -06:00
|
|
|
s.grid.NextRow()
|
|
|
|
|
2024-02-13 12:54:32 -06:00
|
|
|
s.totalOL = gadgets.NewOneLiner(s.grid, "Total")
|
|
|
|
s.grid.NextRow()
|
|
|
|
|
2024-02-17 15:47:46 -06:00
|
|
|
s.totalGoOL = gadgets.NewOneLiner(s.grid, "Total GO")
|
|
|
|
s.grid.NextRow()
|
|
|
|
|
2024-02-13 12:54:32 -06:00
|
|
|
s.dirtyOL = gadgets.NewOneLiner(s.grid, "dirty")
|
|
|
|
s.grid.NextRow()
|
|
|
|
|
|
|
|
s.readonlyOL = gadgets.NewOneLiner(s.grid, "read-only")
|
|
|
|
s.grid.NextRow()
|
|
|
|
|
2024-02-20 10:58:58 -06:00
|
|
|
// s.grid = group1.RawGrid()
|
|
|
|
s.grid.NewLabel("")
|
|
|
|
s.grid.NewLabel("")
|
|
|
|
s.grid.NewLabel("user to devel")
|
|
|
|
s.grid.NewLabel("devel to master")
|
|
|
|
s.grid.NewLabel("master to last tag")
|
|
|
|
s.grid.NextRow()
|
|
|
|
|
|
|
|
s.grid.NewLabel("total modified")
|
|
|
|
s.grid.NewLabel("")
|
|
|
|
s.totalUserRepos = s.grid.NewLabel("x go repos")
|
|
|
|
s.totalDevelRepos = s.grid.NewLabel("")
|
|
|
|
s.totalMasterRepos = s.grid.NewLabel("x go repos")
|
|
|
|
s.grid.NextRow()
|
|
|
|
|
2024-02-13 12:54:32 -06:00
|
|
|
s.totalPatchesOL = gadgets.NewOneLiner(s.grid, "total commits")
|
2024-02-20 10:58:58 -06:00
|
|
|
s.totalUserPatches = s.grid.NewLabel("x patches")
|
|
|
|
s.totalDevelPatches = s.grid.NewLabel("")
|
|
|
|
s.totalMasterPatches = s.grid.NewLabel("x patches")
|
2024-02-18 07:24:56 -06:00
|
|
|
s.grid.NextRow()
|
|
|
|
|
|
|
|
s.grid.NewLabel("")
|
|
|
|
s.grid.NewLabel("")
|
2024-02-21 08:32:59 -06:00
|
|
|
s.grid.NewButton("merge from user", func() {
|
|
|
|
log.Info("this should make a patchset of your patches")
|
|
|
|
})
|
|
|
|
s.grid.NewButton("merge from devel", func() {
|
|
|
|
log.Info("this probably should not exist")
|
|
|
|
})
|
2024-02-13 12:54:32 -06:00
|
|
|
s.grid.NextRow()
|
|
|
|
|
2024-02-18 07:24:56 -06:00
|
|
|
group1 = box.NewGroup("Create GUI Patch Set")
|
|
|
|
s.grid = group1.RawGrid()
|
2024-02-13 13:50:19 -06:00
|
|
|
s.reason = gadgets.NewBasicEntry(s.grid, "patch name:")
|
|
|
|
s.reason.Custom = func() {
|
|
|
|
if s.reason.String() != "" {
|
|
|
|
s.submitB.Enable()
|
|
|
|
} else {
|
|
|
|
s.submitB.Disable()
|
|
|
|
}
|
|
|
|
}
|
2024-02-23 19:29:43 -06:00
|
|
|
s.submitB = s.grid.NewButton("Create Patch Set", func() {
|
2024-11-08 06:45:40 -06:00
|
|
|
dirname := "submit-patchset.quilt"
|
2024-02-23 14:24:31 -06:00
|
|
|
patchdir := filepath.Join(me.userHomePwd.String(), dirname)
|
2024-02-13 21:18:33 -06:00
|
|
|
if shell.Exists(patchdir) {
|
|
|
|
log.Info("patchset dir already exists", patchdir)
|
2024-11-08 06:45:40 -06:00
|
|
|
shell.PathRun(me.userHomePwd.String(), []string{"rm", "-rf", dirname})
|
2024-02-13 21:18:33 -06:00
|
|
|
}
|
2024-02-23 14:24:31 -06:00
|
|
|
shell.Mkdir(patchdir)
|
2024-02-13 21:18:33 -06:00
|
|
|
if !shell.Exists(patchdir) {
|
|
|
|
log.Info("something went wrong making", patchdir)
|
|
|
|
return
|
|
|
|
}
|
2024-02-20 14:58:51 -06:00
|
|
|
me.repos.View.MakePatchset(patchdir)
|
2024-02-13 13:50:19 -06:00
|
|
|
})
|
2024-02-23 19:29:43 -06:00
|
|
|
s.submitB = s.grid.NewButton("Submit quilt", func() {
|
|
|
|
log.Info("do a submit here")
|
|
|
|
})
|
2024-02-13 13:50:19 -06:00
|
|
|
// disable these until there are not dirty repos
|
|
|
|
s.reason.Disable()
|
|
|
|
s.submitB.Disable()
|
2024-02-20 10:58:58 -06:00
|
|
|
s.grid.NextRow()
|
|
|
|
|
2024-12-11 18:50:14 -06:00
|
|
|
// s.unknownOL.Disable()
|
|
|
|
// s.unknownSubmitB.Disable()
|
2024-02-20 10:58:58 -06:00
|
|
|
s.grid.NextRow()
|
2024-02-13 13:50:19 -06:00
|
|
|
|
2024-02-13 12:54:32 -06:00
|
|
|
return s
|
|
|
|
}
|
|
|
|
|
2024-02-20 10:58:58 -06:00
|
|
|
// does not run any commands
|
2024-02-13 13:50:19 -06:00
|
|
|
func (s *patchSummary) Update() {
|
2024-02-17 15:47:46 -06:00
|
|
|
var total, totalgo, dirty, readonly int
|
2024-02-18 07:24:56 -06:00
|
|
|
var userT, develT, masterT int
|
|
|
|
// var userP, develP, masterP int
|
2024-12-02 15:45:06 -06:00
|
|
|
// broken after move to forge protobuf
|
2024-12-11 19:32:04 -06:00
|
|
|
all := me.forge.Repos.SortByGoPath()
|
|
|
|
for all.Scan() {
|
|
|
|
repo := all.Next()
|
2024-02-13 12:54:32 -06:00
|
|
|
total += 1
|
2024-12-02 15:45:06 -06:00
|
|
|
if repo.IsDirty() {
|
2024-02-20 10:58:58 -06:00
|
|
|
dirty += 1
|
2024-02-13 12:54:32 -06:00
|
|
|
}
|
2024-12-02 15:45:06 -06:00
|
|
|
if repo.GetReadOnly() {
|
2024-02-20 11:08:17 -06:00
|
|
|
readonly += 1
|
|
|
|
// don't count these in any further stats
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
// compute which GUI repos are out of sync with master
|
2024-12-02 15:45:06 -06:00
|
|
|
userV := repo.GetUserVersion()
|
|
|
|
develV := repo.GetDevelVersion()
|
|
|
|
masterV := repo.GetMasterVersion()
|
|
|
|
lastV := repo.GetLastTagVersion()
|
2024-02-18 07:24:56 -06:00
|
|
|
if userV != develV {
|
|
|
|
userT += 1
|
|
|
|
}
|
|
|
|
if develV != masterV {
|
2024-12-02 15:45:06 -06:00
|
|
|
log.Info("develV != masterV", develV, masterV, repo.GetGoPath())
|
2024-02-18 07:24:56 -06:00
|
|
|
develT += 1
|
|
|
|
}
|
|
|
|
if masterV != lastV {
|
|
|
|
masterT += 1
|
|
|
|
}
|
2024-02-13 12:54:32 -06:00
|
|
|
}
|
|
|
|
s.totalOL.SetText(strconv.Itoa(total) + " repos")
|
2024-02-17 15:47:46 -06:00
|
|
|
s.totalGoOL.SetText(strconv.Itoa(totalgo) + " repos")
|
2024-02-13 12:54:32 -06:00
|
|
|
s.dirtyOL.SetText(strconv.Itoa(dirty) + " repos")
|
|
|
|
s.readonlyOL.SetText(strconv.Itoa(readonly) + " repos")
|
|
|
|
|
2024-02-18 07:24:56 -06:00
|
|
|
s.totalUserRepos.SetText(strconv.Itoa(userT) + " repos")
|
|
|
|
s.totalDevelRepos.SetText(strconv.Itoa(develT) + " repos")
|
|
|
|
s.totalMasterRepos.SetText(strconv.Itoa(masterT) + " repos")
|
2024-02-20 14:44:12 -06:00
|
|
|
|
|
|
|
if dirty == 0 {
|
|
|
|
s.reason.Enable()
|
|
|
|
s.submitB.Enable()
|
2024-12-11 18:50:14 -06:00
|
|
|
// s.unknownOL.Enable()
|
|
|
|
// s.unknownSubmitB.Enable()
|
2024-02-20 14:44:12 -06:00
|
|
|
} else {
|
|
|
|
s.reason.Disable()
|
|
|
|
s.submitB.Enable()
|
2024-12-11 18:50:14 -06:00
|
|
|
// s.unknownOL.Enable()
|
|
|
|
// s.unknownSubmitB.Enable()
|
2024-02-20 14:44:12 -06:00
|
|
|
}
|
2024-02-13 12:54:32 -06:00
|
|
|
}
|