From 1d50f9eb697591a0c9fb06056b1c0762c9a7f50d Mon Sep 17 00:00:00 2001 From: Jeff Carr Date: Tue, 1 Jul 2025 18:37:11 -0500 Subject: rename --- doFind.go | 169 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ find.go | 169 -------------------------------------------------------------- 2 files changed, 169 insertions(+), 169 deletions(-) create mode 100644 doFind.go delete mode 100644 find.go diff --git a/doFind.go b/doFind.go new file mode 100644 index 0000000..c32a116 --- /dev/null +++ b/doFind.go @@ -0,0 +1,169 @@ +// Copyright 2017-2025 WIT.COM Inc. All rights reserved. +// Use of this source code is governed by the GPL 3.0 + +package main + +import ( + "go.wit.com/lib/protobuf/gitpb" +) + +// this populates a slice of protobuf records representing each git repo +// var me.found []*gitpb.Repo +// +// so, it makes a subset of repos that are then used performing actions on +// +// by default, it adds every repo + +func doFind() *gitpb.Repos { + if argv.List == nil { + return findAll() + } + + if argv.List.Mine { + return findMine() + } + + if argv.List.Dirty { + return findDirty() + } + + return findAll() +} + +func (f *FindCmd) findRepos() *gitpb.Repos { + if f == nil { + return findMine() + } + + if f.All { + return findAll() + } + + if f.Private { + findPrivate() + return me.found + } + + if f.Mine { + return findMine() + } + + if f.Favorites { + findFavorites() + return me.found + } + + if f.Dirty { + return findDirty() + } + + if f.User { + findUser() + return me.found + } + + return findAll() +} + +func findPrivate() { + for repo := range me.forge.Repos.IterByFullPath() { + if me.forge.Config.IsPrivate(repo.GetGoPath()) { + me.found.AppendByGoPath(repo) + } + } +} + +// finds repos that are writable +func findMine() *gitpb.Repos { + found := gitpb.NewRepos() + + // log.Printf("get mine %s\n", me.forge.GetGoSrc()) + for repo := range me.forge.Repos.IterByFullPath() { + + if me.forge.Config.IsWritable(repo.GetGoPath()) { + found.AppendByGoPath(repo) + } + } + return found +} + +// finds repos the user has marked as favorites in the forge .config +func findFavorites() { + // log.Printf("get favorites %s\n", me.forge.GetGoSrc()) + for repo := range me.forge.Repos.IterByFullPath() { + + if me.forge.Config.IsFavorite(repo.GetGoPath()) { + me.found.AppendByGoPath(repo) + } + } +} + +// finds repos that git is reporting as dirty +func findDirty() *gitpb.Repos { + found := gitpb.NewRepos() + for repo := range me.forge.Repos.IterByFullPath() { + if repo.IsDirty() { + found.AppendByGoPath(repo) + } + } + return found +} + +func findAll() *gitpb.Repos { + found := gitpb.NewRepos() + for repo := range me.forge.Repos.IterByFullPath() { + found.AppendByGoPath(repo) + } + return found +} + +func findUser() { + for repo := range me.forge.Repos.IterByFullPath() { + if repo.GetCurrentBranchName() == repo.GetUserBranchName() { + me.found.AppendByGoPath(repo) + } + } +} + +func findPublishable() { + for repo := range me.forge.Repos.IterByFullPath() { + if repo.GetTargetVersion() == "" { + continue + } + me.found.AppendByGoPath(repo) + } +} + +func findReposWithPatches() *gitpb.Repos { + for repo := range me.forge.Repos.IterByFullPath() { + if repo.GetTargetVersion() != "" { + // add everything that has a target version set + me.found.AppendByGoPath(repo) + continue + } + if repo.IsDirty() { + // always add dirty branches + me.found.AppendByGoPath(repo) + continue + } + if repo.GetUserVersion() == "" || repo.GetUserVersion() == "uerr" { + // skip anything without a user branch + continue + } + if repo.GetUserVersion() != repo.GetDevelVersion() { + me.found.AppendByGoPath(repo) + continue + } + + // this is an old test to see if the current 'last tag' is accurate and should be removed + if me.forge.Config.IsReadOnly(repo.GetGoPath()) { + continue + } + if repo.GetLastTag() != repo.GetMasterVersion() { + me.found.AppendByGoPath(repo) + repo.FindLastTag() + continue + } + } + return me.found +} diff --git a/find.go b/find.go deleted file mode 100644 index c32a116..0000000 --- a/find.go +++ /dev/null @@ -1,169 +0,0 @@ -// Copyright 2017-2025 WIT.COM Inc. All rights reserved. -// Use of this source code is governed by the GPL 3.0 - -package main - -import ( - "go.wit.com/lib/protobuf/gitpb" -) - -// this populates a slice of protobuf records representing each git repo -// var me.found []*gitpb.Repo -// -// so, it makes a subset of repos that are then used performing actions on -// -// by default, it adds every repo - -func doFind() *gitpb.Repos { - if argv.List == nil { - return findAll() - } - - if argv.List.Mine { - return findMine() - } - - if argv.List.Dirty { - return findDirty() - } - - return findAll() -} - -func (f *FindCmd) findRepos() *gitpb.Repos { - if f == nil { - return findMine() - } - - if f.All { - return findAll() - } - - if f.Private { - findPrivate() - return me.found - } - - if f.Mine { - return findMine() - } - - if f.Favorites { - findFavorites() - return me.found - } - - if f.Dirty { - return findDirty() - } - - if f.User { - findUser() - return me.found - } - - return findAll() -} - -func findPrivate() { - for repo := range me.forge.Repos.IterByFullPath() { - if me.forge.Config.IsPrivate(repo.GetGoPath()) { - me.found.AppendByGoPath(repo) - } - } -} - -// finds repos that are writable -func findMine() *gitpb.Repos { - found := gitpb.NewRepos() - - // log.Printf("get mine %s\n", me.forge.GetGoSrc()) - for repo := range me.forge.Repos.IterByFullPath() { - - if me.forge.Config.IsWritable(repo.GetGoPath()) { - found.AppendByGoPath(repo) - } - } - return found -} - -// finds repos the user has marked as favorites in the forge .config -func findFavorites() { - // log.Printf("get favorites %s\n", me.forge.GetGoSrc()) - for repo := range me.forge.Repos.IterByFullPath() { - - if me.forge.Config.IsFavorite(repo.GetGoPath()) { - me.found.AppendByGoPath(repo) - } - } -} - -// finds repos that git is reporting as dirty -func findDirty() *gitpb.Repos { - found := gitpb.NewRepos() - for repo := range me.forge.Repos.IterByFullPath() { - if repo.IsDirty() { - found.AppendByGoPath(repo) - } - } - return found -} - -func findAll() *gitpb.Repos { - found := gitpb.NewRepos() - for repo := range me.forge.Repos.IterByFullPath() { - found.AppendByGoPath(repo) - } - return found -} - -func findUser() { - for repo := range me.forge.Repos.IterByFullPath() { - if repo.GetCurrentBranchName() == repo.GetUserBranchName() { - me.found.AppendByGoPath(repo) - } - } -} - -func findPublishable() { - for repo := range me.forge.Repos.IterByFullPath() { - if repo.GetTargetVersion() == "" { - continue - } - me.found.AppendByGoPath(repo) - } -} - -func findReposWithPatches() *gitpb.Repos { - for repo := range me.forge.Repos.IterByFullPath() { - if repo.GetTargetVersion() != "" { - // add everything that has a target version set - me.found.AppendByGoPath(repo) - continue - } - if repo.IsDirty() { - // always add dirty branches - me.found.AppendByGoPath(repo) - continue - } - if repo.GetUserVersion() == "" || repo.GetUserVersion() == "uerr" { - // skip anything without a user branch - continue - } - if repo.GetUserVersion() != repo.GetDevelVersion() { - me.found.AppendByGoPath(repo) - continue - } - - // this is an old test to see if the current 'last tag' is accurate and should be removed - if me.forge.Config.IsReadOnly(repo.GetGoPath()) { - continue - } - if repo.GetLastTag() != repo.GetMasterVersion() { - me.found.AppendByGoPath(repo) - repo.FindLastTag() - continue - } - } - return me.found -} -- cgit v1.2.3