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 /find.go | |
| 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
Diffstat (limited to 'find.go')
| -rw-r--r-- | find.go | 36 |
1 files changed, 10 insertions, 26 deletions
@@ -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) |
