100 lines
1.5 KiB
Go
100 lines
1.5 KiB
Go
package main
|
|
|
|
// by default, work against every repo
|
|
func (f *FindCmd) findRepos() {
|
|
if f == nil {
|
|
findMine()
|
|
return
|
|
}
|
|
|
|
if f.All {
|
|
findAll(f)
|
|
return
|
|
}
|
|
|
|
if f.Private {
|
|
findPrivate()
|
|
return
|
|
}
|
|
|
|
if f.Mine {
|
|
findMine()
|
|
return
|
|
}
|
|
if f.Favorites {
|
|
findFavorites()
|
|
return
|
|
}
|
|
|
|
findAll(f)
|
|
}
|
|
|
|
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() {
|
|
all := me.forge.Repos.SortByFullPath()
|
|
for all.Scan() {
|
|
repo := all.Next()
|
|
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())
|
|
all := me.forge.Repos.SortByFullPath()
|
|
for all.Scan() {
|
|
repo := all.Next()
|
|
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())
|
|
all := me.forge.Repos.SortByFullPath()
|
|
for all.Scan() {
|
|
repo := all.Next()
|
|
if me.forge.Config.IsFavorite(repo.GetGoPath()) {
|
|
me.found.AppendUniqueGoPath(repo)
|
|
}
|
|
}
|
|
}
|
|
|
|
func findAll(fargv *FindCmd) {
|
|
all := me.forge.Repos.SortByFullPath()
|
|
for all.Scan() {
|
|
repo := all.Next()
|
|
me.found.AppendUniqueGoPath(repo)
|
|
}
|
|
}
|