a breath of fresh air. finally can remove all the old code.
This commit is contained in:
parent
b020604931
commit
680069d4ca
24
doGui.go
24
doGui.go
|
@ -13,7 +13,6 @@ import (
|
||||||
"go.wit.com/gui"
|
"go.wit.com/gui"
|
||||||
"go.wit.com/lib/gadgets"
|
"go.wit.com/lib/gadgets"
|
||||||
"go.wit.com/lib/gui/shell"
|
"go.wit.com/lib/gui/shell"
|
||||||
"go.wit.com/lib/protobuf/forgepb"
|
|
||||||
"go.wit.com/lib/protobuf/gitpb"
|
"go.wit.com/lib/protobuf/gitpb"
|
||||||
"go.wit.com/log"
|
"go.wit.com/log"
|
||||||
)
|
)
|
||||||
|
@ -159,6 +158,7 @@ func drawWindow(win *gadgets.GenericWindow) {
|
||||||
}
|
}
|
||||||
// me.forge.GetPatches()
|
// me.forge.GetPatches()
|
||||||
// loadUpstreamPatchsets()
|
// loadUpstreamPatchsets()
|
||||||
|
/*
|
||||||
if me.psets == nil {
|
if me.psets == nil {
|
||||||
log.Info("failed to download current patchsets")
|
log.Info("failed to download current patchsets")
|
||||||
return
|
return
|
||||||
|
@ -177,6 +177,7 @@ func drawWindow(win *gadgets.GenericWindow) {
|
||||||
}
|
}
|
||||||
// savePatchsets()
|
// savePatchsets()
|
||||||
patchesWin = makePatchesWin(notdone)
|
patchesWin = makePatchesWin(notdone)
|
||||||
|
*/
|
||||||
})
|
})
|
||||||
|
|
||||||
var pubWin *gadgets.GenericWindow
|
var pubWin *gadgets.GenericWindow
|
||||||
|
@ -407,27 +408,6 @@ func makeOldStuff() *gadgets.GenericWindow {
|
||||||
|
|
||||||
grid := oldWin.Group.RawGrid()
|
grid := oldWin.Group.RawGrid()
|
||||||
|
|
||||||
var releaseWin *gadgets.GenericWindow
|
|
||||||
grid.NewButton("Release Window", func() {
|
|
||||||
log.Info("todo: move releaser here")
|
|
||||||
log.Info("for now, run guireleaser")
|
|
||||||
if releaseWin != nil {
|
|
||||||
releaseWin.Toggle()
|
|
||||||
return
|
|
||||||
}
|
|
||||||
releaseWin = makeModeMasterWin()
|
|
||||||
})
|
|
||||||
|
|
||||||
var patches *stdPatchsetTableWin
|
|
||||||
grid.NewButton("Patch Window", func() {
|
|
||||||
if patches != nil {
|
|
||||||
patches.Toggle()
|
|
||||||
return
|
|
||||||
}
|
|
||||||
patches = makePatchsetsWin()
|
|
||||||
})
|
|
||||||
grid.NextRow()
|
|
||||||
|
|
||||||
// var reposWin *gadgets.GenericWindow
|
// var reposWin *gadgets.GenericWindow
|
||||||
var reposWin *stdReposTableWin
|
var reposWin *stdReposTableWin
|
||||||
grid.NewButton("Fix Repos", func() {
|
grid.NewButton("Fix Repos", func() {
|
||||||
|
|
64
doPatch.go
64
doPatch.go
|
@ -4,8 +4,6 @@
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
|
||||||
"os"
|
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
|
||||||
"go.wit.com/lib/protobuf/forgepb"
|
"go.wit.com/lib/protobuf/forgepb"
|
||||||
|
@ -69,64 +67,9 @@ func doPatch() error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func doPatchList() error {
|
|
||||||
openPatchsets()
|
|
||||||
if me.psets == nil {
|
|
||||||
return fmt.Errorf("Open Patchsets failed")
|
|
||||||
}
|
|
||||||
log.Info("got psets len", len(me.psets.Patchsets))
|
|
||||||
all := me.psets.SortByName()
|
|
||||||
for all.Scan() {
|
|
||||||
pset := all.Next()
|
|
||||||
// log.Info("pset name =", pset.Name)
|
|
||||||
dumpPatchset(pset)
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func savePatchsets() error {
|
|
||||||
if me.psets == nil {
|
|
||||||
return fmt.Errorf("savePatchesets() can't save nil")
|
|
||||||
}
|
|
||||||
log.Info("savePatchsets() len =", me.psets.Len())
|
|
||||||
data, err := me.psets.Marshal()
|
|
||||||
if err != nil {
|
|
||||||
log.Info("protobuf.Marshal() failed:", err)
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
fullpath := filepath.Join(me.forge.GetConfigDir(), "patchsets.pb")
|
|
||||||
var pfile *os.File
|
|
||||||
pfile, err = os.OpenFile(fullpath, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0644)
|
|
||||||
if err != nil {
|
|
||||||
log.Info("Patchsets save failed:", err, fullpath)
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
pfile.Write(data)
|
|
||||||
pfile.Close()
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func openPatchsets() {
|
|
||||||
fullpath := filepath.Join(me.forge.GetConfigDir(), "patchsets.pb")
|
|
||||||
data, err := os.ReadFile(fullpath)
|
|
||||||
if err != nil {
|
|
||||||
log.Info("Patchsets open failed:", err, fullpath)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
psets := new(forgepb.Patchsets)
|
|
||||||
err = psets.Unmarshal(data)
|
|
||||||
if err != nil {
|
|
||||||
log.Info("Unmarshal patchsets failed", err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
me.psets = psets
|
|
||||||
}
|
|
||||||
|
|
||||||
// returns bad if patches can not be applied
|
// returns bad if patches can not be applied
|
||||||
// logic is not great here but it was a first pass
|
// logic is not great here but it was a first pass
|
||||||
func dumpPatchset(pset *forgepb.Patchset) bool {
|
func dumpPatchset(pset *forgepb.Patchset) bool {
|
||||||
|
|
||||||
// don't even bother to continue if we already know it's broken
|
// don't even bother to continue if we already know it's broken
|
||||||
if pset.State == "BROKEN" {
|
if pset.State == "BROKEN" {
|
||||||
log.Printf("Patchset Name: %-24s Author: %s <%s> IS BAD\n", pset.Name, pset.GetGitAuthorName(), pset.GetGitAuthorEmail())
|
log.Printf("Patchset Name: %-24s Author: %s <%s> IS BAD\n", pset.Name, pset.GetGitAuthorName(), pset.GetGitAuthorEmail())
|
||||||
|
@ -135,13 +78,6 @@ func dumpPatchset(pset *forgepb.Patchset) bool {
|
||||||
log.Printf("Patchset Name: %-24s Author: %s <%s> IS GOOD\n", pset.Name, pset.GetGitAuthorName(), pset.GetGitAuthorEmail())
|
log.Printf("Patchset Name: %-24s Author: %s <%s> IS GOOD\n", pset.Name, pset.GetGitAuthorName(), pset.GetGitAuthorEmail())
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
log.Info("applyPatches() State", pset.State)
|
|
||||||
log.Info("applyPatches() COMMENT", pset.Comment)
|
|
||||||
log.Info("applyPatches() Branch Name", pset.GetStartBranchName())
|
|
||||||
log.Info("applyPatches() Start Hash", pset.GetStartBranchHash())
|
|
||||||
*/
|
|
||||||
|
|
||||||
var count int
|
var count int
|
||||||
var bad int
|
var bad int
|
||||||
all := pset.Patches.SortByFilename()
|
all := pset.Patches.SortByFilename()
|
||||||
|
|
|
@ -10,14 +10,12 @@ import (
|
||||||
"os/exec"
|
"os/exec"
|
||||||
"regexp"
|
"regexp"
|
||||||
"strings"
|
"strings"
|
||||||
"sync"
|
|
||||||
|
|
||||||
"go.wit.com/gui"
|
|
||||||
"go.wit.com/lib/gadgets"
|
|
||||||
"go.wit.com/lib/protobuf/forgepb"
|
"go.wit.com/lib/protobuf/forgepb"
|
||||||
"go.wit.com/log"
|
"go.wit.com/log"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
/*
|
||||||
type stdPatchsetTableWin struct {
|
type stdPatchsetTableWin struct {
|
||||||
sync.Mutex
|
sync.Mutex
|
||||||
win *gadgets.GenericWindow // the machines gui window
|
win *gadgets.GenericWindow // the machines gui window
|
||||||
|
@ -35,157 +33,7 @@ func (w *stdPatchsetTableWin) Toggle() {
|
||||||
}
|
}
|
||||||
w.win.Toggle()
|
w.win.Toggle()
|
||||||
}
|
}
|
||||||
|
|
||||||
func makePatchsetsWin() *stdPatchsetTableWin {
|
|
||||||
dwin := new(stdPatchsetTableWin)
|
|
||||||
dwin.win = gadgets.NewGenericWindow("forge current patchsets", "patchset options")
|
|
||||||
dwin.win.Custom = func() {
|
|
||||||
log.Info("test delete window here")
|
|
||||||
}
|
|
||||||
grid := dwin.win.Group.RawGrid()
|
|
||||||
|
|
||||||
grid.NewButton("ondisk", func() {
|
|
||||||
openPatchsets()
|
|
||||||
if me.psets == nil {
|
|
||||||
log.Info("No Patchsets loaded")
|
|
||||||
return
|
|
||||||
}
|
|
||||||
dwin.doPatchsetsTable(me.psets)
|
|
||||||
})
|
|
||||||
|
|
||||||
grid.NewButton("save", func() {
|
|
||||||
if me.psets == nil {
|
|
||||||
log.Info("No Patchsets loaded")
|
|
||||||
return
|
|
||||||
}
|
|
||||||
savePatchsets()
|
|
||||||
})
|
|
||||||
|
|
||||||
grid.NewButton("set patchset state", func() {
|
|
||||||
if me.psets == nil {
|
|
||||||
log.Info("No Patchsets loaded")
|
|
||||||
return
|
|
||||||
}
|
|
||||||
all := me.psets.All()
|
|
||||||
for all.Scan() {
|
|
||||||
pset := all.Next()
|
|
||||||
if pset.State == "" {
|
|
||||||
log.Info("What is up with?", pset.Name)
|
|
||||||
setPatchsetState(pset)
|
|
||||||
} else {
|
|
||||||
log.Info("patchset already had state", pset.Name, pset.State)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
savePatchsets()
|
|
||||||
})
|
|
||||||
|
|
||||||
grid.NewButton("find commit hashes", func() {
|
|
||||||
if me.psets == nil {
|
|
||||||
log.Info("No Patchsets loaded")
|
|
||||||
return
|
|
||||||
}
|
|
||||||
all := me.psets.All()
|
|
||||||
for all.Scan() {
|
|
||||||
pset := all.Next()
|
|
||||||
if pset.State != "new" {
|
|
||||||
log.Info("patchset already had state", pset.Name, pset.State)
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
if setNewCommitHash(pset) {
|
|
||||||
// everything in this patchset is applied
|
|
||||||
pset.State = "APPLIED"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
savePatchsets()
|
|
||||||
})
|
|
||||||
|
|
||||||
grid.NewButton("show pending patches", func() {
|
|
||||||
if me.psets == nil {
|
|
||||||
log.Info("No Patchsets loaded")
|
|
||||||
return
|
|
||||||
}
|
|
||||||
notdone := new(forgepb.Patches)
|
|
||||||
|
|
||||||
all := me.psets.All()
|
|
||||||
for all.Scan() {
|
|
||||||
pset := all.Next()
|
|
||||||
AddNotDonePatches(notdone, pset, false)
|
|
||||||
}
|
|
||||||
|
|
||||||
for patch := range notdone.IterAll() {
|
|
||||||
comment := cleanSubject(patch.Comment)
|
|
||||||
log.Info("new patch:", patch.NewHash, "commithash:", patch.CommitHash, patch.Namespace, comment)
|
|
||||||
}
|
|
||||||
// savePatchsets()
|
|
||||||
makePatchesWin(notdone)
|
|
||||||
})
|
|
||||||
|
|
||||||
// make a box at the bottom of the window for the protobuf table
|
|
||||||
dwin.box = dwin.win.Bottom.Box().SetProgName("TBOX")
|
|
||||||
|
|
||||||
// load and show the current patch sets
|
|
||||||
openPatchsets()
|
|
||||||
if me.psets == nil {
|
|
||||||
log.Info("Open Patchsets failed")
|
|
||||||
return dwin
|
|
||||||
}
|
|
||||||
dwin.doPatchsetsTable(me.psets)
|
|
||||||
|
|
||||||
return dwin
|
|
||||||
}
|
|
||||||
|
|
||||||
func (dwin *stdPatchsetTableWin) doPatchsetsTable(currentPatchsets *forgepb.Patchsets) {
|
|
||||||
dwin.Lock()
|
|
||||||
defer dwin.Unlock()
|
|
||||||
if dwin.TB != nil {
|
|
||||||
dwin.TB.Delete()
|
|
||||||
dwin.TB = nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// display the protobuf
|
|
||||||
dwin.TB = AddPatchsetsPB(dwin.box, currentPatchsets)
|
|
||||||
f := func(pset *forgepb.Patchset) {
|
|
||||||
log.Info("Triggered. do something here", pset.Name)
|
|
||||||
/*
|
|
||||||
win := makePatchWindow(pset)
|
|
||||||
win.Show()
|
|
||||||
*/
|
*/
|
||||||
}
|
|
||||||
dwin.TB.Custom(f)
|
|
||||||
}
|
|
||||||
|
|
||||||
func AddPatchsetsPB(tbox *gui.Node, pb *forgepb.Patchsets) *forgepb.PatchsetsTable {
|
|
||||||
t := pb.NewTable("PatchsetsPB")
|
|
||||||
t.NewUuid()
|
|
||||||
t.SetParent(tbox)
|
|
||||||
|
|
||||||
t.AddStringFunc("#", func(p *forgepb.Patchset) string {
|
|
||||||
return fmt.Sprintf("%d", p.Patches.Len())
|
|
||||||
})
|
|
||||||
|
|
||||||
vp := t.AddButtonFunc("View Patchset", func(p *forgepb.Patchset) string {
|
|
||||||
return p.Name
|
|
||||||
})
|
|
||||||
vp.Custom = func(pset *forgepb.Patchset) {
|
|
||||||
log.Info("show patches here", pset.Name)
|
|
||||||
makePatchesWin(pset.Patches)
|
|
||||||
// patchwin := makePatchesWin()
|
|
||||||
// patchwin.doPatchesTable(pset.Patches)
|
|
||||||
/*
|
|
||||||
win := makePatchWindow(pset)
|
|
||||||
win.Show()
|
|
||||||
*/
|
|
||||||
}
|
|
||||||
|
|
||||||
t.AddComment()
|
|
||||||
t.AddState()
|
|
||||||
t.AddHostname()
|
|
||||||
|
|
||||||
ctimef := func(p *forgepb.Patchset) string {
|
|
||||||
ctime := p.Ctime.AsTime()
|
|
||||||
return ctime.Format("2006/01/02 15:04")
|
|
||||||
}
|
|
||||||
t.AddStringFunc("ctime", ctimef)
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
etimef := func(e *forgepb.Patchset) string {
|
etimef := func(e *forgepb.Patchset) string {
|
||||||
|
@ -200,24 +48,13 @@ func AddPatchsetsPB(tbox *gui.Node, pb *forgepb.Patchsets) *forgepb.PatchsetsTab
|
||||||
t.AddStringFunc("etime", etimef)
|
t.AddStringFunc("etime", etimef)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
t.AddStringFunc("Author", func(p *forgepb.Patchset) string {
|
/*
|
||||||
return fmt.Sprintf("%s <%s>", p.GitAuthorName, p.GitAuthorEmail)
|
ctimef := func(p *forgepb.Patchset) string {
|
||||||
})
|
ctime := p.Ctime.AsTime()
|
||||||
|
return ctime.Format("2006/01/02 15:04")
|
||||||
t.AddUuid()
|
|
||||||
|
|
||||||
newCommit := t.AddButtonFunc("new hash", func(p *forgepb.Patchset) string {
|
|
||||||
return "find"
|
|
||||||
})
|
|
||||||
newCommit.Custom = func(pset *forgepb.Patchset) {
|
|
||||||
log.Info("find new commits here", pset.Name)
|
|
||||||
// makePatchesWin(pset.Patches)
|
|
||||||
setNewCommitHash(pset)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
t.ShowTable()
|
|
||||||
return t
|
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
func setPatchsetState(p *forgepb.Patchset) {
|
func setPatchsetState(p *forgepb.Patchset) {
|
||||||
var bad bool
|
var bad bool
|
||||||
|
@ -341,6 +178,7 @@ func setNewCommitHash(p *forgepb.Patchset) bool {
|
||||||
return done
|
return done
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
func AddNotDonePatches(notdone *forgepb.Patches, pset *forgepb.Patchset, full bool) {
|
func AddNotDonePatches(notdone *forgepb.Patches, pset *forgepb.Patchset, full bool) {
|
||||||
for patch := range pset.Patches.IterAll() {
|
for patch := range pset.Patches.IterAll() {
|
||||||
comment := cleanSubject(patch.Comment)
|
comment := cleanSubject(patch.Comment)
|
||||||
|
@ -384,3 +222,4 @@ func AddNotDonePatches(notdone *forgepb.Patches, pset *forgepb.Patchset, full bo
|
||||||
notdone.AppendByCommitHash(patch) // double check to ensure the commit hash isn't added twice
|
notdone.AppendByCommitHash(patch) // double check to ensure the commit hash isn't added twice
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
*/
|
|
@ -25,7 +25,6 @@ type mainType struct {
|
||||||
pp *arg.Parser // for parsing the command line args. Yay to alexf lint!
|
pp *arg.Parser // for parsing the command line args. Yay to alexf lint!
|
||||||
forge *forgepb.Forge // for holding the forge protobuf files
|
forge *forgepb.Forge // for holding the forge protobuf files
|
||||||
myGui *gui.Node // the gui toolkit handle
|
myGui *gui.Node // the gui toolkit handle
|
||||||
psets *forgepb.Patchsets // the locally stored on disk patchsets
|
|
||||||
foundPaths []string // stores gopaths to act on (when doing go-clone)
|
foundPaths []string // stores gopaths to act on (when doing go-clone)
|
||||||
configSave bool // if the config file should be saved after finishing
|
configSave bool // if the config file should be saved after finishing
|
||||||
urlbase string // base URL
|
urlbase string // base URL
|
||||||
|
|
|
@ -1,164 +0,0 @@
|
||||||
// Copyright 2017-2025 WIT.COM Inc. All rights reserved.
|
|
||||||
// Use of this source code is governed by the GPL 3.0
|
|
||||||
|
|
||||||
package main
|
|
||||||
|
|
||||||
// this is the "main" patch window. The first one
|
|
||||||
// then you can dig down and examine the patchsets and the files
|
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
"strconv"
|
|
||||||
|
|
||||||
"go.wit.com/lib/gadgets"
|
|
||||||
"go.wit.com/log"
|
|
||||||
|
|
||||||
"go.wit.com/gui"
|
|
||||||
)
|
|
||||||
|
|
||||||
type patchesWindow struct {
|
|
||||||
win *gadgets.BasicWindow // the patches window
|
|
||||||
stack *gui.Node // the top box set as vertical
|
|
||||||
grid *gui.Node // the list of available patches
|
|
||||||
reason *gadgets.BasicEntry // the name of the patchset
|
|
||||||
submitB *gui.Node // the submit patchet button
|
|
||||||
psetgrid *gui.Node // the list of each patchset
|
|
||||||
totalOL *gadgets.OneLiner
|
|
||||||
dirtyOL *gadgets.OneLiner
|
|
||||||
readonlyOL *gadgets.OneLiner
|
|
||||||
rw *gadgets.OneLiner
|
|
||||||
// checkB *gui.Node
|
|
||||||
}
|
|
||||||
|
|
||||||
func (r *patchesWindow) Hidden() bool {
|
|
||||||
return r.win.Hidden()
|
|
||||||
}
|
|
||||||
|
|
||||||
func (r *patchesWindow) Toggle() {
|
|
||||||
if r.Hidden() {
|
|
||||||
r.Show()
|
|
||||||
} else {
|
|
||||||
r.Hide()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (r *patchesWindow) Show() {
|
|
||||||
r.win.Show()
|
|
||||||
}
|
|
||||||
|
|
||||||
func (r *patchesWindow) Hide() {
|
|
||||||
r.win.Hide()
|
|
||||||
}
|
|
||||||
|
|
||||||
// you can only have one of these
|
|
||||||
func (r *patchesWindow) initWindow() {
|
|
||||||
r.win = gadgets.RawBasicWindow("Forge Patchesets")
|
|
||||||
r.win.Make()
|
|
||||||
|
|
||||||
r.stack = r.win.Box().NewBox("bw vbox", false)
|
|
||||||
// me.reposwin.Draw()
|
|
||||||
r.win.Custom = func() {
|
|
||||||
log.Warn("Patchset Window close. setting hidden=true")
|
|
||||||
// sets the hidden flag to false so Toggle() works
|
|
||||||
r.win.Hide()
|
|
||||||
}
|
|
||||||
|
|
||||||
r.grid = r.stack.RawGrid()
|
|
||||||
r.submitPatchesBox()
|
|
||||||
|
|
||||||
// update the stats about the repos and patches
|
|
||||||
r.Update()
|
|
||||||
}
|
|
||||||
|
|
||||||
func (r *patchesWindow) submitPatchesBox() {
|
|
||||||
// s := new(patchSummary)
|
|
||||||
group1 := r.stack.NewGroup("Repo Summary")
|
|
||||||
grid := group1.RawGrid()
|
|
||||||
|
|
||||||
// make the header table for repo stats
|
|
||||||
r.totalOL = gadgets.NewOneLiner(grid, "Total")
|
|
||||||
|
|
||||||
grid.NextRow()
|
|
||||||
r.dirtyOL = gadgets.NewOneLiner(grid, "dirty")
|
|
||||||
grid.NextRow()
|
|
||||||
r.readonlyOL = gadgets.NewOneLiner(grid, "read-only")
|
|
||||||
grid.NextRow()
|
|
||||||
r.rw = gadgets.NewOneLiner(grid, "r/w")
|
|
||||||
grid.NextRow()
|
|
||||||
|
|
||||||
// now, make the 'widget group' and the buttons at the bottom of the window
|
|
||||||
group1 = r.stack.NewGroup("Patchset Create")
|
|
||||||
grid = group1.RawGrid()
|
|
||||||
|
|
||||||
grid.NewButton("show current patches", func() {
|
|
||||||
r.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()
|
|
||||||
*/
|
|
||||||
})
|
|
||||||
|
|
||||||
r.reason = gadgets.NewBasicEntry(grid, "Patchset name:")
|
|
||||||
r.reason.Custom = func() {
|
|
||||||
if r.reason.String() != "" {
|
|
||||||
log.Info("Forge: enable submit")
|
|
||||||
r.submitB.Enable()
|
|
||||||
} else {
|
|
||||||
log.Info("Forge: disable submit")
|
|
||||||
r.submitB.Disable()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
r.submitB = grid.NewButton("Submit", func() {
|
|
||||||
if r.submitB.IsEnabled() {
|
|
||||||
log.Info("submit button is enabled")
|
|
||||||
} else {
|
|
||||||
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)
|
|
||||||
})
|
|
||||||
|
|
||||||
// disables the submit button until the user enters a name
|
|
||||||
r.submitB.Disable()
|
|
||||||
grid.NextRow()
|
|
||||||
}
|
|
||||||
|
|
||||||
// will update this from the current state of the protobuf
|
|
||||||
func (r *patchesWindow) Update() {
|
|
||||||
var total, dirty, readonly, rw int
|
|
||||||
|
|
||||||
// figure out the totals
|
|
||||||
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
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// send the values to the GUI toolkit
|
|
||||||
r.totalOL.SetText(strconv.Itoa(total) + " repos")
|
|
||||||
r.dirtyOL.SetText(strconv.Itoa(dirty) + " repos")
|
|
||||||
r.readonlyOL.SetText(strconv.Itoa(readonly) + " repos")
|
|
||||||
r.rw.SetText(fmt.Sprintf("%d repos", rw))
|
|
||||||
}
|
|
100
windowFound.go
100
windowFound.go
|
@ -1,100 +0,0 @@
|
||||||
// Copyright 2017-2025 WIT.COM Inc. All rights reserved.
|
|
||||||
// Use of this source code is governed by the GPL 3.0
|
|
||||||
|
|
||||||
package main
|
|
||||||
|
|
||||||
// shows a window of the 'found' repos
|
|
||||||
|
|
||||||
import (
|
|
||||||
"go.wit.com/lib/gadgets"
|
|
||||||
"go.wit.com/lib/protobuf/gitpb"
|
|
||||||
"go.wit.com/log"
|
|
||||||
|
|
||||||
"go.wit.com/gui"
|
|
||||||
)
|
|
||||||
|
|
||||||
type foundWindow struct {
|
|
||||||
win *gadgets.BasicWindow // the patches window
|
|
||||||
stack *gui.Node // the top box set as vertical
|
|
||||||
grid *gui.Node // the list of available patches
|
|
||||||
reason *gadgets.BasicEntry // the name of the patchset
|
|
||||||
submitB *gui.Node // the submit patchet button
|
|
||||||
psetgrid *gui.Node // the list of each patchset
|
|
||||||
totalOL *gadgets.OneLiner
|
|
||||||
dirtyOL *gadgets.OneLiner
|
|
||||||
readonlyOL *gadgets.OneLiner
|
|
||||||
rw *gadgets.OneLiner
|
|
||||||
found *gitpb.Repos
|
|
||||||
}
|
|
||||||
|
|
||||||
func (r *foundWindow) Hidden() bool {
|
|
||||||
return r.win.Hidden()
|
|
||||||
}
|
|
||||||
|
|
||||||
func (r *foundWindow) Toggle() {
|
|
||||||
if r.Hidden() {
|
|
||||||
r.Show()
|
|
||||||
} else {
|
|
||||||
r.Hide()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (r *foundWindow) Show() {
|
|
||||||
r.win.Show()
|
|
||||||
}
|
|
||||||
|
|
||||||
func (r *foundWindow) Hide() {
|
|
||||||
r.win.Hide()
|
|
||||||
}
|
|
||||||
|
|
||||||
// you can only have one of these
|
|
||||||
func (r *foundWindow) initWindow() {
|
|
||||||
r.win = gadgets.RawBasicWindow("Found Repos")
|
|
||||||
r.win.Make()
|
|
||||||
|
|
||||||
r.stack = r.win.Box().NewBox("bw vbox", false)
|
|
||||||
// me.reposwin.Draw()
|
|
||||||
r.win.Custom = func() {
|
|
||||||
log.Warn("Found Window close. setting hidden=true")
|
|
||||||
// sets the hidden flag to false so Toggle() works
|
|
||||||
r.win.Hide()
|
|
||||||
}
|
|
||||||
group1 := r.stack.NewGroup("Repo Summary")
|
|
||||||
group1.NewButton("dirty", func() {
|
|
||||||
log.Info("find dirty here")
|
|
||||||
found := me.forge.FindDirty()
|
|
||||||
me.forge.PrintHumanTable(found)
|
|
||||||
})
|
|
||||||
group1.NewButton("all", func() {
|
|
||||||
log.Info("find all here")
|
|
||||||
found := findAll()
|
|
||||||
me.forge.PrintHumanTable(found)
|
|
||||||
})
|
|
||||||
|
|
||||||
r.grid = r.stack.RawGrid()
|
|
||||||
|
|
||||||
group1.NewButton("show", func() {
|
|
||||||
r.listRepos()
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
func (r *foundWindow) listRepos() {
|
|
||||||
for repo := range r.found.IterAll() {
|
|
||||||
r.addRepo(repo)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (r *foundWindow) addRepo(repo *gitpb.Repo) {
|
|
||||||
r.grid.NewButton("View", func() {
|
|
||||||
})
|
|
||||||
r.grid.NewLabel(repo.GetGoPath())
|
|
||||||
r.grid.NewLabel(repo.GetMasterVersion())
|
|
||||||
r.grid.NewLabel(repo.GetDevelVersion())
|
|
||||||
r.grid.NewLabel(repo.GetUserVersion())
|
|
||||||
r.grid.NewLabel(repo.GetCurrentBranchName())
|
|
||||||
r.grid.NextRow()
|
|
||||||
}
|
|
||||||
|
|
||||||
// will update this from the current state of the protobuf
|
|
||||||
func (r *foundWindow) Update() {
|
|
||||||
}
|
|
|
@ -1,102 +0,0 @@
|
||||||
// Copyright 2017-2025 WIT.COM Inc. All rights reserved.
|
|
||||||
// Use of this source code is governed by the GPL 3.0
|
|
||||||
|
|
||||||
package main
|
|
||||||
|
|
||||||
import (
|
|
||||||
"go.wit.com/lib/gadgets"
|
|
||||||
"go.wit.com/lib/protobuf/gitpb"
|
|
||||||
"go.wit.com/log"
|
|
||||||
)
|
|
||||||
|
|
||||||
// An app to submit patches for the 30 GO GUI repos
|
|
||||||
|
|
||||||
func makeModeMasterWin() *gadgets.GenericWindow {
|
|
||||||
win := gadgets.NewGenericWindow("Release", "tools")
|
|
||||||
grid := win.Group.RawGrid()
|
|
||||||
|
|
||||||
grid.NewButton("git checkout master", func() {
|
|
||||||
win.Disable()
|
|
||||||
defer win.Enable()
|
|
||||||
})
|
|
||||||
grid.NewButton("git pull", func() {
|
|
||||||
win.Disable()
|
|
||||||
defer win.Enable()
|
|
||||||
})
|
|
||||||
grid.NextRow()
|
|
||||||
|
|
||||||
grid.NewButton("Clean branches", func() {
|
|
||||||
win.Disable()
|
|
||||||
defer win.Enable()
|
|
||||||
doClean()
|
|
||||||
})
|
|
||||||
|
|
||||||
grid.NextRow()
|
|
||||||
|
|
||||||
grid.NewButton("check repo state", func() {
|
|
||||||
win.Disable()
|
|
||||||
defer win.Enable()
|
|
||||||
})
|
|
||||||
|
|
||||||
grid.NewButton("reset user branches (?)", func() {
|
|
||||||
resetUserBranchesWindow()
|
|
||||||
})
|
|
||||||
return win
|
|
||||||
}
|
|
||||||
|
|
||||||
func resetUserBranchesWindow() {
|
|
||||||
found := gitpb.NewRepos()
|
|
||||||
all := me.forge.Repos.SortByFullPath()
|
|
||||||
for all.Scan() {
|
|
||||||
repo := all.Next()
|
|
||||||
uname := repo.GetUserBranchName()
|
|
||||||
dname := repo.GetDevelBranchName()
|
|
||||||
if repo.GetCurrentBranchName() == uname {
|
|
||||||
log.Info("Repo is on the user branch. Can't delete it.", repo.GetGoPath())
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
b1 := repo.CountDiffObjects(uname, dname)
|
|
||||||
b2 := repo.CountDiffObjects(dname, uname)
|
|
||||||
log.Info("user vs devel count", b1, b2)
|
|
||||||
if b1 == 0 && b2 == 0 {
|
|
||||||
cmd := []string{"git", "branch", "-D", uname}
|
|
||||||
log.Info(repo.GetGoPath(), cmd)
|
|
||||||
repo.RunVerbose(cmd)
|
|
||||||
repo.Reload()
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
found.Append(repo)
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
win := gadgets.RawBasicWindow("reset user branches")
|
|
||||||
win.Make()
|
|
||||||
win.Show()
|
|
||||||
win.Custom = func() {
|
|
||||||
// sets the hidden flag to false so Toggle() works
|
|
||||||
win.Hide()
|
|
||||||
}
|
|
||||||
box := win.Box().NewBox("bw vbox", false)
|
|
||||||
|
|
||||||
group := box.NewGroup("test buttons")
|
|
||||||
hbox := group.Box().Horizontal()
|
|
||||||
hbox.NewButton("force delete user branch", func() {
|
|
||||||
win.Disable()
|
|
||||||
defer win.Enable()
|
|
||||||
all := found.SortByFullPath()
|
|
||||||
for all.Scan() {
|
|
||||||
repo := all.Next()
|
|
||||||
brname := repo.GetUserBranchName()
|
|
||||||
cmd := []string{"git", "branch", "-D", brname}
|
|
||||||
log.Info(repo.GetGoPath(), cmd)
|
|
||||||
repo.RunVerbose(cmd)
|
|
||||||
repo.Reload()
|
|
||||||
}
|
|
||||||
me.forge.SetConfigSave(true)
|
|
||||||
me.forge.ConfigSave()
|
|
||||||
})
|
|
||||||
|
|
||||||
t := makeStandardReposGrid(found)
|
|
||||||
t.SetParent(box)
|
|
||||||
t.ShowTable()
|
|
||||||
}
|
|
|
@ -58,6 +58,7 @@ func makePatchesWin(patches *forgepb.Patches) *stdPatchTableWin {
|
||||||
grid.NextRow()
|
grid.NextRow()
|
||||||
|
|
||||||
grid.NewButton("show all", func() {
|
grid.NewButton("show all", func() {
|
||||||
|
/*
|
||||||
if me.psets == nil {
|
if me.psets == nil {
|
||||||
log.Info("No Patchsets loaded")
|
log.Info("No Patchsets loaded")
|
||||||
return
|
return
|
||||||
|
@ -75,6 +76,7 @@ func makePatchesWin(patches *forgepb.Patches) *stdPatchTableWin {
|
||||||
log.Info("new patch:", patch.NewHash, "commithash:", patch.CommitHash, patch.Namespace, comment)
|
log.Info("new patch:", patch.NewHash, "commithash:", patch.CommitHash, patch.Namespace, comment)
|
||||||
}
|
}
|
||||||
dwin.doPatchesTable(notdone)
|
dwin.doPatchesTable(notdone)
|
||||||
|
*/
|
||||||
})
|
})
|
||||||
|
|
||||||
grid.NewButton("Update", func() {
|
grid.NewButton("Update", func() {
|
||||||
|
|
Loading…
Reference in New Issue