From 1a255bdbf64f2cb0f87e532bed82cce42f77a741 Mon Sep 17 00:00:00 2001 From: Jeff Carr Date: Fri, 21 Feb 2025 18:31:26 -0600 Subject: [PATCH] start deprecating me.found --- Makefile | 2 +- applyPatch.go | 5 ++--- doCommit.go | 5 ++--- doDirty.go | 17 ++++------------- doGui.go | 27 +++++++++++++++++++-------- find.go | 24 +++++++++++++----------- main.go | 6 ++---- windowFound.go | 5 ++--- windowRepoProblems.go | 3 --- 9 files changed, 45 insertions(+), 49 deletions(-) diff --git a/Makefile b/Makefile index 1f9f1e5..9eec491 100644 --- a/Makefile +++ b/Makefile @@ -32,7 +32,7 @@ install-raw: goimports vet plugin plugin: rm -f resources/*.so - -cp ../../toolkits/gocui/gocui.so resources/ + # -cp ../../toolkits/gocui/gocui.so resources/ andlabs: install forge --gui andlabs --debugger diff --git a/applyPatch.go b/applyPatch.go index 9d70ff4..9abafef 100644 --- a/applyPatch.go +++ b/applyPatch.go @@ -51,9 +51,8 @@ func IsAnythingDirty() bool { me.found = new(gitpb.Repos) findAll() // select all the repos doCheckDirtyAndConfigSave() - me.found = new(gitpb.Repos) - findDirty() - if len(me.found.Repos) == 0 { + found := findDirty() + if found.Len() == 0 { return false } else { return true diff --git a/doCommit.go b/doCommit.go index 829340b..b7f6fde 100644 --- a/doCommit.go +++ b/doCommit.go @@ -15,9 +15,8 @@ func doCommit() { if argv.All { log.Info("do a commit everywhere") doCheckDirtyAndConfigSave() - me.found = new(gitpb.Repos) - findDirty() - all := me.found.All() + found := findDirty() + all := found.All() for all.Scan() { repo := all.Next() log.Info("do a commit on repo", repo.GetGoPath()) diff --git a/doDirty.go b/doDirty.go index cdca518..0380bd0 100644 --- a/doDirty.go +++ b/doDirty.go @@ -14,12 +14,11 @@ import ( func doDirty() { findAll() // select all the repos doCheckDirtyAndConfigSave() - me.found = new(gitpb.Repos) - findDirty() + found := findDirty() if argv.Verbose { - me.forge.PrintHumanTableDirty(me.found) + me.forge.PrintHumanTableDirty(found) } else { - me.forge.PrintHumanTable(me.found) + me.forge.PrintHumanTable(found) } } @@ -51,15 +50,7 @@ func doCheckDirty(repo *gitpb.Repo) error { func doCheckDirtyAndConfigSave() { start := straightCheckDirty() - // log.Info("before findAll()") - /* - all := me.found.All() - for all.Scan() { - repo := all.Next() - repo.CheckDirty() - } - */ - // this might work? + now := time.Now() me.forge.RillFuncError(doCheckDirty) end := straightCheckDirty() diff --git a/doGui.go b/doGui.go index 869588a..ec436d7 100644 --- a/doGui.go +++ b/doGui.go @@ -21,7 +21,7 @@ import ( ) func debug() { - time.Sleep(5 * time.Second) + time.Sleep(2 * time.Second) for { now := time.Now() tmp := fmt.Sprintf("All (%d)", me.forge.Repos.Len()) @@ -45,8 +45,9 @@ func debug() { tmp = fmt.Sprintf("writable (%d)", me.found.Len()) me.repoWritableB.SetLabel(tmp) - doDirty() - tmp = fmt.Sprintf("dirty (%d)", me.found.Len()) + doCheckDirtyAndConfigSave() + found := findDirty() + tmp = fmt.Sprintf("dirty (%d)", found.Len()) me.repoDirtyB.SetLabel(tmp) log.Printf("finished a forge scan here in (%s)\n", shell.FormatDuration(time.Since(now))) @@ -197,9 +198,19 @@ func drawWindow(win *gadgets.BasicWindow) { grid = group2.RawGrid() me.repoDirtyB = grid.NewButton("dirty", func() { - me.found = new(gitpb.Repos) - findDirty() - makeStandardReposWindow("dirty repos", me.found) + doCheckDirtyAndConfigSave() + found := findDirty() + _, box := makeStandardReposWindow("dirty repos", found) + box.NewButton("commit all", func() { + all := found.SortByFullPath() + for all.Scan() { + repo := all.Next() + log.Info("do commit here on", repo.GetGoPath()) + } + log.Info("TODO: fix this") + log.Info("run 'forge commit --all'") + }) + }) me.repoWritableB = grid.NewButton("writable", func() { @@ -360,7 +371,7 @@ func makeStandardReposGrid(pb *gitpb.Repos) *gitpb.ReposTable { } // this is the magic that generates a window directly from the protocol buffer -func makeStandardReposWindow(title string, pb *gitpb.Repos) *gitpb.ReposTable { +func makeStandardReposWindow(title string, pb *gitpb.Repos) (*gitpb.ReposTable, *gui.Node) { win := gadgets.RawBasicWindow(title) win.Make() win.Show() @@ -373,7 +384,7 @@ func makeStandardReposWindow(title string, pb *gitpb.Repos) *gitpb.ReposTable { t := makeStandardReposGrid(pb) t.SetParent(box) t.ShowTable() - return t + return t, box } func findMergeToDevel() { diff --git a/find.go b/find.go index 493e3cc..1173be4 100644 --- a/find.go +++ b/find.go @@ -14,43 +14,43 @@ import ( // // by default, it adds every repo -func (f *FindCmd) findRepos() { +func (f *FindCmd) findRepos() *gitpb.Repos { if f == nil { findMine() - return + return me.found } if f.All { findAll() - return + return me.found } if f.Private { findPrivate() - return + return me.found } if f.Mine { findMine() - return + return me.found } if f.Favorites { findFavorites() - return + return me.found } if f.Dirty { - findDirty() - return + return findDirty() } if f.User { findUser() - return + return me.found } findAll() + return me.found } func findPrivate() { @@ -89,15 +89,17 @@ func findFavorites() { } // finds repos that git is reporting as dirty -func findDirty() { +func findDirty() *gitpb.Repos { + found := gitpb.NewRepos() all := me.forge.Repos.SortByFullPath() for all.Scan() { var repo *gitpb.Repo repo = all.Next() if repo.IsDirty() { - me.found.AppendByGoPath(repo) + found.AppendByGoPath(repo) } } + return found } func findAll() { diff --git a/main.go b/main.go index 82c4897..b9d4004 100644 --- a/main.go +++ b/main.go @@ -152,21 +152,19 @@ func main() { } if argv.GitFetch != nil { - // argv.GitPull.findRepos() doGitFetch() okExit("") } if argv.GitPull != nil { - // argv.GitPull.findRepos() doGitPullNew() okExit("") } if argv.List != nil { - argv.List.findRepos() + found := argv.List.findRepos() // print out the repos - me.forge.PrintHumanTable(me.found) + me.forge.PrintHumanTable(found) okExit("") } diff --git a/windowFound.go b/windowFound.go index 4639835..9b085f1 100644 --- a/windowFound.go +++ b/windowFound.go @@ -62,9 +62,8 @@ func (r *foundWindow) initWindow() { group1 := r.stack.NewGroup("Repo Summary") group1.NewButton("dirty", func() { log.Info("find dirty here") - me.found = new(gitpb.Repos) - findDirty() - me.forge.PrintHumanTable(me.found) + found := findDirty() + me.forge.PrintHumanTable(found) }) group1.NewButton("all", func() { log.Info("find all here") diff --git a/windowRepoProblems.go b/windowRepoProblems.go index 876c4c4..1f61fd1 100644 --- a/windowRepoProblems.go +++ b/windowRepoProblems.go @@ -99,9 +99,6 @@ func makeRepoProblemsWindow() *repoProblemsWindow { group.NewButton("hello", func() { log.Info("world") }) - group.NewButton("list", func() { - log.Info("world") - }) t := makeStandardReposGrid(found) t.SetParent(box)