summaryrefslogtreecommitdiff
path: root/doFind.go
diff options
context:
space:
mode:
authorJeff Carr <[email protected]>2025-10-07 20:43:43 -0500
committerJeff Carr <[email protected]>2025-10-07 20:43:43 -0500
commit34ac2291bc0d9321b078cf70f81684fc4d14e7e8 (patch)
tree3fa312d39fb1d39b9d0c565d04ead4f9cc151fd5 /doFind.go
parent2b01cc8c01a82bf8c5fbecea831e61660d9103f7 (diff)
make "Fix" subcommand
Diffstat (limited to 'doFind.go')
-rw-r--r--doFind.go197
1 files changed, 0 insertions, 197 deletions
diff --git a/doFind.go b/doFind.go
deleted file mode 100644
index f6fbbba..0000000
--- a/doFind.go
+++ /dev/null
@@ -1,197 +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 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.Show == nil {
- return findAll()
- }
-
- if argv.Show.Repo.Mine {
- return findMine()
- }
-
- if argv.Show.Dirty != nil {
- return me.forge.FindDirty()
- }
-
- return findAll()
-}
-
-func findRepos() *gitpb.Repos {
- if argv.Show == nil {
- return findMine()
- }
-
- if argv.Show.Dirty != nil {
- return me.forge.FindDirty()
- }
-
- if argv.Show.Repo == nil {
- return findAll()
- }
-
- if argv.Show.Repo.All {
- return findAll()
- }
-
- if argv.Show.Repo.Private {
- return findPrivate()
- }
-
- if argv.Show.Repo.Mine {
- return findMine()
- }
-
- if argv.Show.Repo.Favorites {
- return findFavorites()
- }
-
- if argv.Show.Repo.User {
- return findUser()
- }
-
- return findAll()
-}
-
-func findPrivate() *gitpb.Repos {
- found := gitpb.NewRepos()
- for repo := range me.forge.Repos.IterByFullPath() {
- if me.forge.Config.IsPrivate(repo.Namespace) {
- found.AppendByFullPath(repo)
- }
- }
-
- return found
-}
-
-// 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.Namespace) {
- found.AppendByFullPath(repo)
- }
- }
- return found
-}
-
-// finds repos the user has marked as favorites in the forge .config
-func findFavorites() *gitpb.Repos {
- found := gitpb.NewRepos()
-
- // log.Printf("get favorites %s\n", me.forge.GetGoSrc())
- for repo := range me.forge.Repos.IterByFullPath() {
-
- if me.forge.Config.IsFavorite(repo.Namespace) {
- found.AppendByFullPath(repo)
- }
- }
- return found
-}
-
-func findAll() *gitpb.Repos {
- found := gitpb.NewRepos()
- for repo := range me.forge.Repos.IterByFullPath() {
- found.AppendByFullPath(repo)
- }
- return found
-}
-
-func find50() *gitpb.Repos {
- count := 0
- found := gitpb.NewRepos()
- for repo := range me.forge.Repos.IterByFullPath() {
- found.AppendByFullPath(repo)
- if count > 50 {
- return found
- }
- count += 1
- }
- return found
-}
-
-func findUser() *gitpb.Repos {
- found := gitpb.NewRepos()
-
- for repo := range me.forge.Repos.IterByFullPath() {
- if repo.GetCurrentBranchName() == repo.GetUserBranchName() {
- found.AppendByFullPath(repo)
- }
- }
- return found
-}
-
-func findPublishable() *gitpb.Repos {
- found := gitpb.NewRepos()
-
- for repo := range me.forge.Repos.IterByFullPath() {
- if repo.GetTargetVersion() == "" {
- continue
- }
- found.AppendByFullPath(repo)
- }
- return found
-}
-
-func findReposWithPatches() *gitpb.Repos {
- found := gitpb.NewRepos()
-
- for repo := range me.forge.Repos.IterByFullPath() {
- if repo.IsDirty() {
- // always add dirty branches
- found.AppendByFullPath(repo)
- continue
- }
- if repo.GetUserVersion() == "" || repo.GetUserVersion() == "uerr" {
- // skip anything without a user branch
- continue
- }
- if repo.GetUserVersion() != repo.GetDevelVersion() {
- found.AppendByFullPath(repo)
- continue
- }
-
- // ignore read-only repos for checks below here
- if me.forge.Config.IsReadOnly(repo.Namespace) {
- continue
- }
-
- // show anything that differs between 'devel' & 'master' branches
- if repo.GetDevelVersion() != repo.GetMasterVersion() {
- // this repo.State code isn't great, but it got me here quickly
- // I'll defend my code by saying it's faster for me if I do dumb things
- // sometimes and fix them later. Probably some employee will have to
- // fix this. if that is the case I owe you lunch. or stock options
- if repo.State == "DEVEL behind MASTER" {
- // log.Info("repo state", repo.FullPath, repo.State)
- continue
- }
- found.AppendByFullPath(repo)
- continue
- }
-
- // this is an old test to see if the current 'last tag' is accurate and should be removed
- if repo.GetLastTag() != repo.GetMasterVersion() {
- found.AppendByFullPath(repo)
- repo.FindLastTag()
- continue
- }
- }
- return found
-}