forge/findConfig.go

86 lines
1.6 KiB
Go

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
}
}
}