2024-02-12 15:24:35 -06:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
2025-01-06 19:03:35 -06:00
|
|
|
"fmt"
|
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-12 15:24:35 -06:00
|
|
|
"go.wit.com/log"
|
|
|
|
)
|
|
|
|
|
2024-02-13 13:50:19 -06:00
|
|
|
type patchSummary struct {
|
2025-01-06 19:03:35 -06:00
|
|
|
grid *gui.Node
|
|
|
|
updateB *gui.Node
|
|
|
|
docsB *gui.Node
|
|
|
|
gitPushB *gui.Node
|
|
|
|
gitPullB *gui.Node
|
|
|
|
checkB *gui.Node
|
|
|
|
totalOL *gadgets.OneLiner
|
2024-02-18 07:24:56 -06:00
|
|
|
dirtyOL *gadgets.OneLiner
|
|
|
|
readonlyOL *gadgets.OneLiner
|
2025-01-06 19:03:35 -06:00
|
|
|
rw *gadgets.OneLiner
|
2024-02-18 07:24:56 -06:00
|
|
|
totalPatchesOL *gadgets.OneLiner
|
|
|
|
totalUserRepos *gui.Node
|
|
|
|
totalDevelRepos *gui.Node
|
|
|
|
totalMasterRepos *gui.Node
|
|
|
|
totalUserPatches *gui.Node
|
|
|
|
totalDevelPatches *gui.Node
|
|
|
|
totalMasterPatches *gui.Node
|
2025-01-06 19:03:35 -06:00
|
|
|
fileCount *gui.Node
|
|
|
|
unknownOL *gadgets.BasicEntry
|
|
|
|
unknownSubmitB *gui.Node
|
|
|
|
reason *gadgets.BasicEntry
|
|
|
|
submitB *gui.Node
|
2025-01-07 18:06:29 -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-12-23 02:37:48 -06:00
|
|
|
group1 := box.NewGroup("Patch Summary")
|
2024-02-13 12:54:32 -06:00
|
|
|
s.grid = group1.RawGrid()
|
|
|
|
|
|
|
|
s.totalOL = gadgets.NewOneLiner(s.grid, "Total")
|
2025-01-06 19:03:35 -06:00
|
|
|
_ = s.grid.NewLabel("total changes")
|
|
|
|
_ = s.grid.NewLabel("user to devel")
|
2024-02-13 12:54:32 -06:00
|
|
|
s.grid.NextRow()
|
|
|
|
|
|
|
|
s.dirtyOL = gadgets.NewOneLiner(s.grid, "dirty")
|
2025-01-06 19:03:35 -06:00
|
|
|
_ = s.grid.NewLabel("") // skip a column
|
2024-02-20 10:58:58 -06:00
|
|
|
s.totalUserRepos = s.grid.NewLabel("x go repos")
|
|
|
|
s.grid.NextRow()
|
|
|
|
|
2025-01-06 19:03:35 -06:00
|
|
|
s.readonlyOL = gadgets.NewOneLiner(s.grid, "read-only")
|
|
|
|
_ = s.grid.NewLabel("") // skip a column
|
2024-02-20 10:58:58 -06:00
|
|
|
s.totalUserPatches = s.grid.NewLabel("x patches")
|
2024-02-18 07:24:56 -06:00
|
|
|
s.grid.NextRow()
|
|
|
|
|
2025-01-06 19:03:35 -06:00
|
|
|
s.rw = gadgets.NewOneLiner(s.grid, "r/w")
|
|
|
|
_ = s.grid.NewLabel("") // skip a column
|
|
|
|
s.fileCount = s.grid.NewLabel("x files")
|
2024-02-13 12:54:32 -06:00
|
|
|
s.grid.NextRow()
|
|
|
|
|
2024-12-23 02:37:48 -06:00
|
|
|
group1 = box.NewGroup("Submit Patch Set")
|
2024-02-18 07:24:56 -06:00
|
|
|
s.grid = group1.RawGrid()
|
2024-12-23 02:37:48 -06:00
|
|
|
s.reason = gadgets.NewBasicEntry(s.grid, "set name:")
|
2024-02-13 13:50:19 -06:00
|
|
|
s.reason.Custom = func() {
|
|
|
|
if s.reason.String() != "" {
|
|
|
|
s.submitB.Enable()
|
|
|
|
} else {
|
|
|
|
s.submitB.Disable()
|
|
|
|
}
|
|
|
|
}
|
2024-12-23 02:37:48 -06:00
|
|
|
s.submitB = s.grid.NewButton("Submit", func() {
|
2024-12-29 21:36:39 -06:00
|
|
|
if err := sendDevelDiff(s.reason.String()); err != nil {
|
|
|
|
log.Info("sending patches failed", err)
|
|
|
|
} else {
|
|
|
|
log.Info("sent patch set ok")
|
|
|
|
}
|
2024-02-13 13:50:19 -06:00
|
|
|
})
|
2025-01-05 02:01:15 -06:00
|
|
|
|
2025-01-05 04:54:05 -06:00
|
|
|
s.grid.NewButton("List Patchsets", func() {
|
2024-12-23 11:15:16 -06:00
|
|
|
listPatches()
|
|
|
|
})
|
2025-01-05 02:01:15 -06:00
|
|
|
|
2025-01-05 04:54:05 -06:00
|
|
|
s.grid.NewButton("Show Latest Patchset", func() {
|
2025-01-05 02:01:15 -06:00
|
|
|
lastp := lastPatch()
|
|
|
|
pset, err := getPatch(lastp)
|
|
|
|
if err != nil {
|
|
|
|
return
|
|
|
|
}
|
2025-01-05 04:54:05 -06:00
|
|
|
|
|
|
|
if !dumpPatchset(pset) {
|
|
|
|
log.Info("some patches are bad")
|
|
|
|
return
|
|
|
|
}
|
|
|
|
if IsAnythingDirty() {
|
|
|
|
log.Info("You can't apply patches when repos are dirty")
|
2025-01-08 00:51:53 -06:00
|
|
|
me.forge.PrintHumanTable(me.found)
|
2025-01-05 04:54:05 -06:00
|
|
|
return
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
|
|
|
s.grid.NewButton("Apply Latest Patchset", func() {
|
|
|
|
lastp := lastPatch()
|
|
|
|
pset, err := getPatch(lastp)
|
|
|
|
if err != nil {
|
|
|
|
return
|
|
|
|
}
|
2025-01-05 05:48:02 -06:00
|
|
|
if !IsEverythingOnDevel() {
|
|
|
|
log.Info("You can only apply patches to the devel branch")
|
|
|
|
return
|
|
|
|
}
|
2025-01-05 04:54:05 -06:00
|
|
|
if IsAnythingDirty() {
|
|
|
|
log.Info("You can't apply patches when repos are dirty")
|
2025-01-08 00:51:53 -06:00
|
|
|
me.forge.PrintHumanTable(me.found)
|
2025-01-05 04:54:05 -06:00
|
|
|
return
|
|
|
|
}
|
|
|
|
applyPatchset(pset)
|
2025-01-05 02:01:15 -06:00
|
|
|
})
|
|
|
|
|
2024-12-23 03:27:29 -06:00
|
|
|
s.grid.NewButton("Show Repos", func() {
|
|
|
|
s.Update()
|
|
|
|
if me.repos.Hidden() {
|
|
|
|
me.repos.Show()
|
|
|
|
} else {
|
|
|
|
me.repos.Hide()
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
2024-02-13 13:50:19 -06:00
|
|
|
// disable these until there are not dirty repos
|
2024-12-23 02:37:48 -06:00
|
|
|
// s.reason.Disable()
|
2024-02-13 13:50:19 -06:00
|
|
|
s.submitB.Disable()
|
2024-02-20 10:58:58 -06:00
|
|
|
s.grid.NextRow()
|
|
|
|
|
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() {
|
2025-01-06 19:03:35 -06:00
|
|
|
var total, dirty, readonly, rw int
|
|
|
|
var userT int // , develT, masterT int
|
2024-02-18 07:24:56 -06:00
|
|
|
// var userP, develP, masterP int
|
2024-12-02 15:45:06 -06:00
|
|
|
// broken after move to forge protobuf
|
2024-12-17 06:36:00 -06:00
|
|
|
all := me.forge.Repos.SortByFullPath()
|
2024-12-11 19:32:04 -06:00
|
|
|
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
|
|
|
}
|
2025-01-06 19:03:35 -06:00
|
|
|
if me.forge.Config.IsReadOnly(repo.GetGoPath()) {
|
2024-02-20 11:08:17 -06:00
|
|
|
readonly += 1
|
2025-01-06 19:03:35 -06:00
|
|
|
} else {
|
|
|
|
rw += 1
|
2024-02-18 07:24:56 -06:00
|
|
|
}
|
2024-02-13 12:54:32 -06:00
|
|
|
}
|
|
|
|
s.totalOL.SetText(strconv.Itoa(total) + " repos")
|
|
|
|
s.dirtyOL.SetText(strconv.Itoa(dirty) + " repos")
|
|
|
|
s.readonlyOL.SetText(strconv.Itoa(readonly) + " repos")
|
2025-01-06 19:03:35 -06:00
|
|
|
s.rw.SetText(fmt.Sprintf("%d repos", rw))
|
2024-02-13 12:54:32 -06:00
|
|
|
|
2024-02-18 07:24:56 -06:00
|
|
|
s.totalUserRepos.SetText(strconv.Itoa(userT) + " repos")
|
2024-02-13 12:54:32 -06:00
|
|
|
}
|