summaryrefslogtreecommitdiff
path: root/findRepos.go
diff options
context:
space:
mode:
Diffstat (limited to 'findRepos.go')
-rw-r--r--findRepos.go91
1 files changed, 71 insertions, 20 deletions
diff --git a/findRepos.go b/findRepos.go
index 1463d09..18ddd03 100644
--- a/findRepos.go
+++ b/findRepos.go
@@ -4,37 +4,88 @@ import (
"go.wit.com/log"
)
-func findRepos() {
+func findRepos() bool {
+ var done bool = false
if argv.FindAll {
- var configsave bool
- repos := me.forge.Repos.SortByGoPath()
- for repos.Scan() {
- repo := repos.Next()
- if me.forge.Config.IsReadOnly(repo.GoPath) && !argv.FindReadOnly {
- if repo.ReadOnly {
- continue
- }
- log.Info("todo: ConfigSave() readonly flag on repo is wrong", repo.GoPath)
- repo.ReadOnly = true
- configsave = true
- continue
- }
- me.found.AppendUniqueGoPath(repo)
- }
- if configsave {
- log.Info("should ConfigSave here")
- me.forge.Repos.ConfigSave()
- }
+ 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() {
+ 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 favorites %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)
+ }
+ }
+}
+
+func findAll() {
+ var configsave bool
+ repos := me.forge.Repos.SortByGoPath()
+ for repos.Scan() {
+ repo := repos.Next()
+ if me.forge.Config.IsReadOnly(repo.GoPath) && !argv.FindReadOnly {
+ if repo.ReadOnly {
+ continue
+ }
+ log.Info("todo: ConfigSave() readonly flag on repo is wrong", repo.GoPath)
+ repo.ReadOnly = true
+ configsave = true
+ continue
+ }
+ me.found.AppendUniqueGoPath(repo)
+ }
+ if configsave {
+ log.Info("should ConfigSave here")
+ me.forge.Repos.ConfigSave()
}
}