93 lines
1.7 KiB
Go
93 lines
1.7 KiB
Go
package main
|
|
|
|
import (
|
|
"go.wit.com/log"
|
|
)
|
|
|
|
func findRepos() bool {
|
|
var done bool = false
|
|
if argv.FindAll {
|
|
findAll()
|
|
done = true
|
|
}
|
|
|
|
if argv.FindPrivate {
|
|
findPrivate()
|
|
done = true
|
|
}
|
|
|
|
if argv.FindMine {
|
|
findMine()
|
|
done = true
|
|
}
|
|
if argv.FindFavorites {
|
|
findFavorites()
|
|
done = true
|
|
}
|
|
|
|
// 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() {
|
|
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() {
|
|
all := me.forge.Repos.SortByFullPath()
|
|
for all.Scan() {
|
|
repo := all.Next()
|
|
me.found.AppendUniqueGoPath(repo)
|
|
if me.forge.Config.IsReadOnly(repo.GetGoPath()) && !argv.FindReadOnly {
|
|
if repo.ReadOnly {
|
|
continue
|
|
}
|
|
log.Info("todo: ConfigSave() readonly flag on repo is wrong", repo.GetGoPath())
|
|
repo.ReadOnly = true
|
|
configSave = true
|
|
continue
|
|
}
|
|
}
|
|
/*
|
|
if configsave {
|
|
log.Info("should ConfigSave here")
|
|
me.forge.Repos.ConfigSave()
|
|
}
|
|
*/
|
|
}
|