2024-12-05 12:29:47 -06:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"go.wit.com/log"
|
|
|
|
)
|
|
|
|
|
2024-12-05 14:17:50 -06:00
|
|
|
func findRepos() bool {
|
|
|
|
var done bool = false
|
2024-12-24 01:54:33 -06:00
|
|
|
if argv.Find != nil {
|
|
|
|
if argv.Find.All {
|
|
|
|
findAll()
|
|
|
|
done = true
|
|
|
|
}
|
2024-12-05 12:29:47 -06:00
|
|
|
|
2024-12-24 01:54:33 -06:00
|
|
|
if argv.Find.Private {
|
|
|
|
findPrivate()
|
|
|
|
done = true
|
|
|
|
}
|
2024-12-05 12:29:47 -06:00
|
|
|
|
2024-12-24 01:54:33 -06:00
|
|
|
if argv.Find.Mine {
|
|
|
|
findMine()
|
|
|
|
done = true
|
|
|
|
}
|
|
|
|
if argv.Find.Favorites {
|
|
|
|
findFavorites()
|
|
|
|
done = true
|
|
|
|
}
|
2024-12-05 14:17:50 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
// this is the 'default' behavior when no command line arguments are given
|
|
|
|
// if no argv was set, select repos marked as 'mine'
|
|
|
|
if !done {
|
|
|
|
findMine()
|
|
|
|
done = true
|
|
|
|
}
|
|
|
|
return done
|
|
|
|
}
|
|
|
|
|
|
|
|
func findPrivate() {
|
2024-12-17 06:36:00 -06:00
|
|
|
all := me.forge.Repos.SortByFullPath()
|
2024-12-11 19:32:04 -06:00
|
|
|
for all.Scan() {
|
|
|
|
repo := all.Next()
|
2024-12-17 06:36:00 -06:00
|
|
|
if me.forge.Config.IsPrivate(repo.GetGoPath()) {
|
2024-12-05 14:17:50 -06:00
|
|
|
me.found.AppendUniqueGoPath(repo)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// finds repos that are writable
|
|
|
|
func findMine() {
|
|
|
|
// log.Printf("get mine %s\n", me.forge.GetGoSrc())
|
2024-12-17 06:36:00 -06:00
|
|
|
all := me.forge.Repos.SortByFullPath()
|
2024-12-11 19:32:04 -06:00
|
|
|
for all.Scan() {
|
|
|
|
repo := all.Next()
|
2024-12-17 06:36:00 -06:00
|
|
|
if me.forge.Config.IsWritable(repo.GetGoPath()) {
|
2024-12-05 14:17:50 -06:00
|
|
|
me.found.AppendUniqueGoPath(repo)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// finds repos that are writable
|
|
|
|
func findFavorites() {
|
|
|
|
// log.Printf("get favorites %s\n", me.forge.GetGoSrc())
|
2024-12-17 06:36:00 -06:00
|
|
|
all := me.forge.Repos.SortByFullPath()
|
2024-12-11 19:32:04 -06:00
|
|
|
for all.Scan() {
|
|
|
|
repo := all.Next()
|
2024-12-17 06:36:00 -06:00
|
|
|
if me.forge.Config.IsFavorite(repo.GetGoPath()) {
|
2024-12-05 14:17:50 -06:00
|
|
|
me.found.AppendUniqueGoPath(repo)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func findAll() {
|
2024-12-17 06:36:00 -06:00
|
|
|
all := me.forge.Repos.SortByFullPath()
|
2024-12-11 19:32:04 -06:00
|
|
|
for all.Scan() {
|
|
|
|
repo := all.Next()
|
2024-12-13 17:13:07 -06:00
|
|
|
me.found.AppendUniqueGoPath(repo)
|
2024-12-24 01:54:33 -06:00
|
|
|
if me.forge.Config.IsReadOnly(repo.GetGoPath()) && !argv.Find.ReadOnly {
|
2024-12-05 14:17:50 -06:00
|
|
|
if repo.ReadOnly {
|
|
|
|
continue
|
|
|
|
}
|
2024-12-17 06:36:00 -06:00
|
|
|
log.Info("todo: ConfigSave() readonly flag on repo is wrong", repo.GetGoPath())
|
2024-12-05 14:17:50 -06:00
|
|
|
repo.ReadOnly = true
|
2024-12-13 17:13:07 -06:00
|
|
|
configSave = true
|
2024-12-05 14:17:50 -06:00
|
|
|
continue
|
|
|
|
}
|
2024-12-05 12:29:47 -06:00
|
|
|
}
|
2024-12-13 17:13:07 -06:00
|
|
|
/*
|
|
|
|
if configsave {
|
|
|
|
log.Info("should ConfigSave here")
|
|
|
|
me.forge.Repos.ConfigSave()
|
|
|
|
}
|
|
|
|
*/
|
2024-12-05 12:29:47 -06:00
|
|
|
}
|