summaryrefslogtreecommitdiff
path: root/windowPatchesSubmit.go
diff options
context:
space:
mode:
authorJeff Carr <[email protected]>2025-01-29 09:06:19 -0600
committerJeff Carr <[email protected]>2025-01-29 12:18:16 -0600
commitf2281a2102d5821d337029a9f36395b955f3ec80 (patch)
treeeca9f11c59c8c3ca7dda42eee2d73b4a529a3c66 /windowPatchesSubmit.go
parentb047d706795074a63cbbfd771bdd6787fa80a9ab (diff)
start a 'view patch' window
Diffstat (limited to 'windowPatchesSubmit.go')
-rw-r--r--windowPatchesSubmit.go120
1 files changed, 120 insertions, 0 deletions
diff --git a/windowPatchesSubmit.go b/windowPatchesSubmit.go
new file mode 100644
index 0000000..518e7e1
--- /dev/null
+++ b/windowPatchesSubmit.go
@@ -0,0 +1,120 @@
+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 (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()
+ })
+
+ 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() {
+ pset, err := me.forge.SubmitDevelPatchSet(s.reason.String())
+ if err != nil {
+ log.Info(err)
+ return
+ }
+ line := "somedate " + s.reason.String() + " Author: me" + pset.GitAuthorEmail
+ me.patchWin.addPatchset(line)
+ })
+
+ // 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")
+}