From 816760d1372d6d1922a9916f3150e49f3fd562cd Mon Sep 17 00:00:00 2001 From: Jeff Carr Date: Thu, 5 Dec 2024 12:29:47 -0600 Subject: developing on this now --- findConfig.go | 85 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 85 insertions(+) create mode 100644 findConfig.go (limited to 'findConfig.go') diff --git a/findConfig.go b/findConfig.go new file mode 100644 index 0000000..34c8f18 --- /dev/null +++ b/findConfig.go @@ -0,0 +1,85 @@ +package main + +import "go.wit.com/log" + +func findPrivate() { + repos := me.forge.Repos.SortByGoPath() + for repos.Scan() { + repo := repos.Next() + if me.forge.Config.IsPrivate(repo.GoPath) { + me.found.AppendUniqueGoPath(repo) + } + } +} + +// finds repos that are writable +func findMine() { + log.Printf("get mine %s\n", me.forge.GetGoSrc()) + repos := me.forge.Repos.SortByGoPath() + for repos.Scan() { + repo := repos.Next() + if me.forge.Config.IsWritable(repo.GoPath) { + me.found.AppendUniqueGoPath(repo) + } + } +} + +// finds repos that are writable +func findFavorites() { + log.Printf("get mine %s\n", me.forge.GetGoSrc()) + repos := me.forge.Repos.SortByGoPath() + for repos.Scan() { + repo := repos.Next() + if me.forge.Config.IsFavorite(repo.GoPath) { + me.found.AppendUniqueGoPath(repo) + } + } +} + +// retuns true if nothing was done +func findConfig() bool { + if argv.FindMine { + findConfigMine() + return false + } + if argv.FindAll { + findConfigAll() + return false + } + + return true +} + +// finds config repos that are writable +func findConfigMine() { + loop := me.forge.Config.SortByGoPath() + for loop.Scan() { + r := loop.Next() + gopath := r.GoPath + if r.GetDirectory() { + continue + } + if me.forge.Config.IsWritable(gopath) { + log.Info("mine:", gopath) + me.foundPaths = append(me.foundPaths, gopath) + continue + } + } +} + +// get everything in your config +func findConfigAll() { + loop := me.forge.Config.SortByGoPath() + for loop.Scan() { + r := loop.Next() + gopath := r.GoPath + if r.GetDirectory() { + continue + } + if me.forge.Config.IsWritable(gopath) { + log.Info("mine:", gopath) + me.foundPaths = append(me.foundPaths, gopath) + continue + } + } +} -- cgit v1.2.3