forge/findRepos.go

100 lines
1.5 KiB
Go
Raw Normal View History

2024-12-05 12:29:47 -06:00
package main
2024-12-27 04:36:29 -06:00
// by default, work against every repo
2024-12-27 03:39:53 -06:00
func (f *FindCmd) findRepos() {
if f == nil {
findMine()
return
}
2024-12-05 12:29:47 -06:00
2024-12-27 03:39:53 -06:00
if f.All {
findAll(f)
return
}
2024-12-05 12:29:47 -06:00
2024-12-27 03:39:53 -06:00
if f.Private {
findPrivate()
return
}
2024-12-27 03:39:53 -06:00
if f.Mine {
findMine()
2024-12-27 03:39:53 -06:00
return
}
if f.Favorites {
findFavorites()
return
}
2024-12-27 03:39:53 -06:00
2024-12-27 04:36:29 -06:00
findAll(f)
2024-12-27 03:39:53 -06:00
}
func findRepos(fargv *FindCmd) {
if fargv == nil {
findMine()
return
}
if fargv.All {
findAll(fargv)
return
}
if fargv.Private {
findPrivate()
return
}
if fargv.Mine {
findMine()
return
}
if fargv.Favorites {
findFavorites()
return
}
findMine()
}
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()) {
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()) {
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()) {
me.found.AppendUniqueGoPath(repo)
}
}
}
2024-12-27 03:39:53 -06:00
func findAll(fargv *FindCmd) {
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-05 12:29:47 -06:00
}
}