From 24988d440cf7a7919c964447b8997390ac28da0b Mon Sep 17 00:00:00 2001 From: Jeff Carr Date: Tue, 28 Jan 2025 23:59:12 -0600 Subject: rethink doVerify() strategy. put in the GUI instead --- doVerifyUser.go | 55 +++++++++++++++++++ windowPatches.go | 2 + windowPatchesSummary.go | 140 ++++++++++++++++++++++++++++++++++++++++++++++++ windowSummary.go | 140 ------------------------------------------------ 4 files changed, 197 insertions(+), 140 deletions(-) create mode 100644 doVerifyUser.go create mode 100644 windowPatchesSummary.go delete mode 100644 windowSummary.go diff --git a/doVerifyUser.go b/doVerifyUser.go new file mode 100644 index 0000000..8c1013c --- /dev/null +++ b/doVerifyUser.go @@ -0,0 +1,55 @@ +package main + +import ( + "go.wit.com/lib/protobuf/gitpb" + "go.wit.com/log" +) + +func doVerifyUser() error { + me.found = new(gitpb.Repos) + all := me.forge.Repos.SortByFullPath() + for all.Scan() { + repo := all.Next() + if repo.IsDirty() { + log.Info(repo.GetGoPath(), "is dirty") + me.found.AppendByGoPath(repo) + continue + } + if repo.ExistsUserBranchRemote() { + } + + if repo.ExistsUserBranch() { + } + if repo.GetMasterBranchName() == repo.GetCurrentBranchName() { + log.Info(repo.GetGoPath(), "is not on master branch") + continue + } + + devel := repo.GetDevelBranchName() + if argv.Verbose { + log.Printf("Start clean devel branch: %s %s\n", repo.GetGoPath(), devel) + } + + // check if devel branch exists in remote repo + if repo.IsBranchRemote(devel) { + if err := doCleanDevelRepo(repo); err != nil { + log.Info(repo.GetGoPath(), "verify clean failed") + } + // can not continue + continue + } + // devel branch is only local + /* + todo: something? + devname := repo.GetDevelBranchName() + if err := requiresGitPush(repo, devname); err != nil { + log.Info(repo.GetGoPath(), "is out of sync with upstream") + return err + } + */ + } + return nil +} + +func verifyRemoteUserBranch(repo *gitpb.Repo) { +} diff --git a/windowPatches.go b/windowPatches.go index 793afb8..ad14e7f 100644 --- a/windowPatches.go +++ b/windowPatches.go @@ -1,6 +1,7 @@ package main import ( + "slices" "strings" "sync" @@ -90,6 +91,7 @@ func (r *patchesWindow) initWindow() { log.Info(err) return } + slices.Reverse(lines) for i, line := range lines { log.Info(i, line) r.addPatchset(line) diff --git a/windowPatchesSummary.go b/windowPatchesSummary.go new file mode 100644 index 0000000..5be64f7 --- /dev/null +++ b/windowPatchesSummary.go @@ -0,0 +1,140 @@ +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) + }) + + /* + 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 deleted file mode 100644 index a5c4879..0000000 --- a/windowSummary.go +++ /dev/null @@ -1,140 +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 (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 some reason Author: me" + pset.GitAuthorEmail - me.patchWin.addPatchset(line) - }) - - /* - 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