diff options
| author | Jeff Carr <[email protected]> | 2025-03-19 07:05:16 -0500 |
|---|---|---|
| committer | Jeff Carr <[email protected]> | 2025-03-19 07:05:16 -0500 |
| commit | fd9cefdb761966ad9f37cf39425d5b983863bbab (patch) | |
| tree | 07dbb3613995dd6c17f0254b8bd492fcf7686528 | |
| parent | 9aa086e7c41c9297ab7a19d4f536d5d79fffeaac (diff) | |
switch some things to Iter()v0.22.110
The Iter() syntax is nice and simple. In some
cases, the Scan() / Next() syntax is more readable
and maybe better for new programmers to understand. notsure
| -rw-r--r-- | doDirty.go | 4 | ||||
| -rw-r--r-- | doGui.go | 31 | ||||
| -rw-r--r-- | find.go | 36 | ||||
| -rw-r--r-- | windowFound.go | 4 |
4 files changed, 15 insertions, 60 deletions
@@ -26,9 +26,7 @@ func straightCheckDirty() int { var count int // var total int // now := time.Now() - all := me.found.All() - for all.Scan() { - repo := all.Next() + for repo := range me.found.IterAll() { // total += 1 if repo.IsDirty() { count += 1 @@ -36,9 +36,7 @@ func debug() { if me.repoWritableB != nil { found := gitpb.NewRepos() - all := me.forge.Repos.SortByFullPath() - for all.Scan() { - repo := all.Next() + for repo := range me.forge.Repos.IterByFullPath() { if me.forge.Config.IsReadOnly(repo.GetGoPath()) { continue } @@ -291,28 +289,6 @@ func forgeSwitchMode(newMode forgepb.ForgeMode) { me.forge.Config.ConfigSave() } -/* -func doDisableUserW() { - me.argvCheckoutUser = false - - var count int - all := me.forge.Repos.SortByFullPath() - for all.Scan() { - repo := all.Next() - if !repo.IsLocalBranch(repo.GetUserBranchName()) { - // log.Info("repo doesn't have user branch", repo.GetGoPath()) - continue - } - count += 1 - } - - if count > 0 { - s := fmt.Sprintf("git delete %d user branches", count) - return - } -} -*/ - // this is the magic that generates a window directly from the protocol buffer func makeStandardReposGrid(pb *gitpb.Repos) *gitpb.ReposTable { t := pb.NewTable("testDirty") @@ -356,9 +332,7 @@ func makeStandardReposWindow(title string, pb *gitpb.Repos) (*gitpb.ReposTable, func findMergeToDevel() *gitpb.Repos { found := gitpb.NewRepos() - all := me.forge.Repos.SortByFullPath() - for all.Scan() { - repo := all.Next() + for repo := range me.forge.Repos.IterByFullPath() { // this sees if user has patches for devel. If it does, add it to me.found if repo.CountDiffObjects(repo.GetUserBranchName(), repo.GetDevelBranchName()) > 0 { @@ -383,6 +357,7 @@ func findMergeToMaster() { all := me.forge.Repos.SortByFullPath() for all.Scan() { repo := all.Next() + if me.forge.Config.IsReadOnly(repo.GetGoPath()) { continue } @@ -54,10 +54,7 @@ func (f *FindCmd) findRepos() *gitpb.Repos { } func findPrivate() { - all := me.forge.Repos.SortByFullPath() - for all.Scan() { - repo := all.Next() - + for repo := range me.forge.Repos.IterByFullPath() { if me.forge.Config.IsPrivate(repo.GetGoPath()) { me.found.AppendByGoPath(repo) } @@ -67,9 +64,8 @@ func findPrivate() { // finds repos that are writable func findMine() { // log.Printf("get mine %s\n", me.forge.GetGoSrc()) - all := me.forge.Repos.SortByFullPath() - for all.Scan() { - repo := all.Next() + for repo := range me.forge.Repos.IterByFullPath() { + if me.forge.Config.IsWritable(repo.GetGoPath()) { me.found.AppendByGoPath(repo) } @@ -79,9 +75,8 @@ func findMine() { // finds repos the user has marked as favorites in the forge .config func findFavorites() { // log.Printf("get favorites %s\n", me.forge.GetGoSrc()) - all := me.forge.Repos.SortByFullPath() - for all.Scan() { - repo := all.Next() + for repo := range me.forge.Repos.IterByFullPath() { + if me.forge.Config.IsFavorite(repo.GetGoPath()) { me.found.AppendByGoPath(repo) } @@ -91,10 +86,7 @@ func findFavorites() { // finds repos that git is reporting as dirty func findDirty() *gitpb.Repos { found := gitpb.NewRepos() - all := me.forge.Repos.SortByFullPath() - for all.Scan() { - var repo *gitpb.Repo - repo = all.Next() + for repo := range me.forge.Repos.IterByFullPath() { if repo.IsDirty() { found.AppendByGoPath(repo) } @@ -103,17 +95,13 @@ func findDirty() *gitpb.Repos { } func findAll() { - all := me.forge.Repos.SortByFullPath() - for all.Scan() { - repo := all.Next() + for repo := range me.forge.Repos.IterByFullPath() { me.found.AppendByGoPath(repo) } } func findUser() { - all := me.forge.Repos.SortByFullPath() - for all.Scan() { - repo := all.Next() + for repo := range me.forge.Repos.IterByFullPath() { if repo.GetCurrentBranchName() == repo.GetUserBranchName() { me.found.AppendByGoPath(repo) } @@ -121,9 +109,7 @@ func findUser() { } func findPublishable() { - all := me.forge.Repos.SortByFullPath() - for all.Scan() { - repo := all.Next() + for repo := range me.forge.Repos.IterByFullPath() { if repo.GetTargetVersion() == "" { continue } @@ -132,9 +118,7 @@ func findPublishable() { } func findReposWithPatches() { - all := me.forge.Repos.SortByFullPath() - for all.Scan() { - repo := all.Next() + for repo := range me.forge.Repos.IterByFullPath() { if repo.GetTargetVersion() != "" { // add everything that has a target version set me.found.AppendByGoPath(repo) diff --git a/windowFound.go b/windowFound.go index 9b085f1..c79e514 100644 --- a/windowFound.go +++ b/windowFound.go @@ -80,9 +80,7 @@ func (r *foundWindow) initWindow() { } func (r *foundWindow) listRepos() { - all := me.found.All() - for all.Scan() { - repo := all.Next() + for repo := range me.found.IterAll() { r.addRepo(repo) } } |
