From 1ba66e4e547d255db32be4daf0fed07e976b2770 Mon Sep 17 00:00:00 2001 From: Jeff Carr Date: Mon, 20 Jan 2025 02:51:50 -0600 Subject: mv --- windowMain.go | 42 --------------- windowNew.go | 94 -------------------------------- windowPatches.go | 94 ++++++++++++++++++++++++++++++++ windowPatchesBox.go | 151 ---------------------------------------------------- windowSummary.go | 151 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 245 insertions(+), 287 deletions(-) delete mode 100644 windowMain.go delete mode 100644 windowNew.go create mode 100644 windowPatches.go delete mode 100644 windowPatchesBox.go create mode 100644 windowSummary.go diff --git a/windowMain.go b/windowMain.go deleted file mode 100644 index 0d46dc6..0000000 --- a/windowMain.go +++ /dev/null @@ -1,42 +0,0 @@ -package main - -import ( - "os" - - "go.wit.com/lib/gui/shell" - "go.wit.com/log" -) - -func doesExist(path string) bool { - if _, err := os.Stat(path); err != nil { - if os.IsNotExist(err) { - return false - } - } - return true -} - -// only errors on bad errors -func quickCmd(fullpath string, cmd []string) bool { - if me.autoDryRun.Checked() { - log.Warn("RUN --dry-run", fullpath, cmd) - return false - } else { - log.Warn("RUN:", fullpath, cmd) - } - - result := shell.PathRun(fullpath, cmd) - if result.Error != nil { - log.Warn("quickCmd() cmd =", cmd) - log.Warn("quickCmd() err =", result.Error) - log.Warn("quickCmd() b =", result.Exit) - log.Warn("quickCmd() output =", result.Stdout) - return false - } else if result.Exit != 0 { - log.Warn("quickCmd() b =", result.Exit) - log.Warn("quickCmd() output =", result.Stdout) - return true - } - log.Warn("quickCmd() output = ", result.Stdout) - return true -} diff --git a/windowNew.go b/windowNew.go deleted file mode 100644 index cab0323..0000000 --- a/windowNew.go +++ /dev/null @@ -1,94 +0,0 @@ -package main - -import ( - "sync" - - "go.wit.com/lib/gadgets" - "go.wit.com/log" - - "go.wit.com/gui" -) - -type patchesWindow struct { - once sync.Once - win *gadgets.BasicWindow - stack *gui.Node - - // the top box of the repolist window - shelf *gui.Node - - summary *patchSummary -} - -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() -} - -func (r *patchesWindow) Disable() { - r.stack.Disable() -} - -func (r *patchesWindow) Enable() { - r.stack.Enable() -} - -// you can only have one of these -func (r *patchesWindow) initWindow() { - // sync.Once() - 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.shelf = r.initGroup() - r.summary = submitPatchesBox(r.stack) -} - -func (r *patchesWindow) initGroup() *gui.Node { - // reposbox.SetExpand(false) - group1 := r.stack.NewGroup("stuff") - - vbox := group1.Box() - // hbox.Horizontal() - vbox.Vertical() - - hbox := vbox.Box().Horizontal() - /* - */ - - dirty := hbox.NewCheckbox("dirty") - dirty.Custom = func() { - log.Info("filter dirty =", dirty.Checked()) - } - - hbox.NewButton("update patch summary", func() { - r.summary.Update() - }) - hbox.NewButton("test add", func() { - me.patchWin.initGroup() - }) - - return vbox -} diff --git a/windowPatches.go b/windowPatches.go new file mode 100644 index 0000000..cab0323 --- /dev/null +++ b/windowPatches.go @@ -0,0 +1,94 @@ +package main + +import ( + "sync" + + "go.wit.com/lib/gadgets" + "go.wit.com/log" + + "go.wit.com/gui" +) + +type patchesWindow struct { + once sync.Once + win *gadgets.BasicWindow + stack *gui.Node + + // the top box of the repolist window + shelf *gui.Node + + summary *patchSummary +} + +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() +} + +func (r *patchesWindow) Disable() { + r.stack.Disable() +} + +func (r *patchesWindow) Enable() { + r.stack.Enable() +} + +// you can only have one of these +func (r *patchesWindow) initWindow() { + // sync.Once() + 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.shelf = r.initGroup() + r.summary = submitPatchesBox(r.stack) +} + +func (r *patchesWindow) initGroup() *gui.Node { + // reposbox.SetExpand(false) + group1 := r.stack.NewGroup("stuff") + + vbox := group1.Box() + // hbox.Horizontal() + vbox.Vertical() + + hbox := vbox.Box().Horizontal() + /* + */ + + dirty := hbox.NewCheckbox("dirty") + dirty.Custom = func() { + log.Info("filter dirty =", dirty.Checked()) + } + + hbox.NewButton("update patch summary", func() { + r.summary.Update() + }) + hbox.NewButton("test add", func() { + me.patchWin.initGroup() + }) + + return vbox +} diff --git a/windowPatchesBox.go b/windowPatchesBox.go deleted file mode 100644 index 30c34cb..0000000 --- a/windowPatchesBox.go +++ /dev/null @@ -1,151 +0,0 @@ -package main - -import ( - "fmt" - "strconv" - - "go.wit.com/gui" - "go.wit.com/lib/gadgets" - "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 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("Submit Patch Set") - s.grid = group1.RawGrid() - s.reason = gadgets.NewBasicEntry(s.grid, "set name:") - s.reason.Custom = func() { - if s.reason.String() != "" { - s.submitB.Enable() - } else { - s.submitB.Disable() - } - } - s.submitB = s.grid.NewButton("Submit", func() { - doSubmit(s.reason.String()) - }) - - s.grid.NewButton("List Patchsets", func() { - if err := listPatches(); err != nil { - log.Info(err) - } - }) - - s.grid.NewButton("Show Latest Patchset", func() { - lastp := lastPatch() - pset, err := getPatch(lastp) - if err != nil { - return - } - - if !dumpPatchset(pset) { - log.Info("some patches are bad") - return - } - if IsAnythingDirty() { - log.Info("You can't apply patches when repos are dirty") - me.forge.PrintHumanTable(me.found) - return - } - }) - - s.grid.NewButton("Apply Latest Patchset", func() { - lastp := lastPatch() - pset, err := getPatch(lastp) - if err != nil { - return - } - if _, _, err := IsEverythingOnDevel(); err != nil { - log.Info("You can only apply patches to the devel branch") - return - } - if IsAnythingDirty() { - log.Info("You can't apply patches when repos are dirty") - me.forge.PrintHumanTable(me.found) - return - } - applyPatchset(pset) - }) - - // disable these until there are not dirty repos - // s.reason.Disable() - s.submitB.Disable() - s.grid.NextRow() - return s -} - -// 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") -} diff --git a/windowSummary.go b/windowSummary.go new file mode 100644 index 0000000..30c34cb --- /dev/null +++ b/windowSummary.go @@ -0,0 +1,151 @@ +package main + +import ( + "fmt" + "strconv" + + "go.wit.com/gui" + "go.wit.com/lib/gadgets" + "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 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("Submit Patch Set") + s.grid = group1.RawGrid() + s.reason = gadgets.NewBasicEntry(s.grid, "set name:") + s.reason.Custom = func() { + if s.reason.String() != "" { + s.submitB.Enable() + } else { + s.submitB.Disable() + } + } + s.submitB = s.grid.NewButton("Submit", func() { + doSubmit(s.reason.String()) + }) + + s.grid.NewButton("List Patchsets", func() { + if err := listPatches(); err != nil { + log.Info(err) + } + }) + + s.grid.NewButton("Show Latest Patchset", func() { + lastp := lastPatch() + pset, err := getPatch(lastp) + if err != nil { + return + } + + if !dumpPatchset(pset) { + log.Info("some patches are bad") + return + } + if IsAnythingDirty() { + log.Info("You can't apply patches when repos are dirty") + me.forge.PrintHumanTable(me.found) + return + } + }) + + s.grid.NewButton("Apply Latest Patchset", func() { + lastp := lastPatch() + pset, err := getPatch(lastp) + if err != nil { + return + } + if _, _, err := IsEverythingOnDevel(); err != nil { + log.Info("You can only apply patches to the devel branch") + return + } + if IsAnythingDirty() { + log.Info("You can't apply patches when repos are dirty") + me.forge.PrintHumanTable(me.found) + return + } + applyPatchset(pset) + }) + + // disable these until there are not dirty repos + // s.reason.Disable() + s.submitB.Disable() + s.grid.NextRow() + return s +} + +// 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") +} -- cgit v1.2.3