summaryrefslogtreecommitdiff
path: root/list.go
diff options
context:
space:
mode:
Diffstat (limited to 'list.go')
-rw-r--r--list.go98
1 files changed, 58 insertions, 40 deletions
diff --git a/list.go b/list.go
index 661e3e2..3110d5a 100644
--- a/list.go
+++ b/list.go
@@ -10,34 +10,25 @@ import (
func list() {
log.DaemonMode(true)
- if argv.ListConf {
- me.forge.ConfigPrintTable()
- os.Exit(0)
+ if argv.Private {
+ // GetPrivate()
+ return
}
- if argv.Private {
+ if argv.Mine {
+ log.Printf("get mine %s\n", me.forge.GetGoSrc())
repos := me.forge.Repos.SortByGoPath()
for repos.Scan() {
repo := repos.Next()
- if me.forge.IsPrivate(repo.GoPath) {
+ if me.forge.Config.IsWritable(repo.GoPath) {
verifyPrint(repo)
}
}
- configs := me.forge.Config.SortByGoPath()
- for configs.Scan() {
- thing := configs.Next()
- if thing.Directory {
- continue
- }
- if thing.Private {
- found := me.forge.Repos.FindByGoPath(thing.GoPath)
- if found == nil {
- log.Info("have not downloaded private:", thing.GoPath)
- } else {
- log.Info("already downloaded private:", thing.GoPath)
- }
- }
- }
+ os.Exit(0)
+ }
+
+ if argv.Favorites {
+ log.Printf("get favorites\n")
os.Exit(0)
}
@@ -46,7 +37,7 @@ func list() {
repos := me.forge.Repos.SortByGoPath()
for repos.Scan() {
repo := repos.Next()
- if me.forge.IsReadOnly(repo) && !argv.ReadOnly {
+ if me.forge.Config.IsReadOnly(repo.GoPath) && !argv.ReadOnly {
if repo.ReadOnly {
continue
}
@@ -63,16 +54,6 @@ func list() {
}
os.Exit(0)
}
-
- if argv.GetMine {
- log.Printf("get mine %s", me.forge.GetGoSrc())
- os.Exit(0)
- }
-
- if argv.GetFav {
- log.Printf("get favorites")
- os.Exit(0)
- }
}
func verifyPrint(repo *gitpb.Repo) {
@@ -83,7 +64,7 @@ func verifyPrint(repo *gitpb.Repo) {
s := make(map[string]string)
if !verify(repo, s) {
log.Info("going to delete", repo.GoPath)
- if argv.Real {
+ if argv.Fix {
me.forge.Repos.DeleteByGoPath(repo.GetGoPath())
me.forge.Repos.ConfigSave()
} else {
@@ -91,21 +72,32 @@ func verifyPrint(repo *gitpb.Repo) {
os.Exit(0)
}
}
- if me.forge.IsReadOnly(repo) && !argv.ReadOnly {
+ if me.forge.Config.IsReadOnly(repo.GoPath) && !argv.ReadOnly {
if repo.ReadOnly {
return
}
log.Info("readonly flag on repo is wrong", repo.GoPath)
return
}
- start := fmt.Sprintf("%-40s %-8s %-20s %-20s %-20s", s["gopath"], s["rtype"], s["cver"], s["mver"], s["cver"])
- //if s["url"] != "" {
- // end += "(" + s["url"] + ") "
- //}
- if repo.ReadOnly {
+ slen := 12
+ var chort string = s["cver"]
+ var mhort string = s["mver"]
+ var uhort string = s["uver"]
+ if len(s["cver"]) > slen {
+ chort = s["cver"][:slen]
+ }
+ if len(s["mver"]) > slen {
+ mhort = s["mver"][:slen]
+ }
+ if len(s["uver"]) > slen {
+ uhort = s["uver"][:slen]
+ }
+ start := fmt.Sprintf("%-40s %-12s %-12s %-12s %-8s", s["gopath"], chort, mhort, uhort, s["rtype"])
+
+ if me.forge.Config.IsReadOnly(repo.GoPath) {
end += "(readonly) "
}
- // end += fmt.Sprintf("(%s,%s,%s,%s) ", s["mname"], s["dname"], s["uname"], s["cname"])
+
log.Info(start, end)
}
@@ -123,7 +115,7 @@ func verify(repo *gitpb.Repo, s map[string]string) bool {
return false
}
// only verify the master branch name with read-only repos
- if me.forge.IsReadOnly(repo) {
+ if me.forge.Config.IsReadOnly(repo.GoPath) {
s["mver"] = repo.GetMasterVersion()
return true
}
@@ -160,3 +152,29 @@ func verify(repo *gitpb.Repo, s map[string]string) bool {
return true
}
+
+func listPrivate() {
+ repos := me.forge.Repos.SortByGoPath()
+ for repos.Scan() {
+ repo := repos.Next()
+ if me.forge.Config.IsPrivate(repo.GoPath) {
+ verifyPrint(repo)
+ }
+ }
+ configs := me.forge.Config.SortByGoPath()
+ for configs.Scan() {
+ thing := configs.Next()
+ if thing.Directory {
+ continue
+ }
+ if thing.Private {
+ found := me.forge.Repos.FindByGoPath(thing.GoPath)
+ if found == nil {
+ log.Info("have not downloaded private:", thing.GoPath)
+ } else {
+ log.Info("already downloaded private:", thing.GoPath)
+ }
+ }
+ }
+ os.Exit(0)
+}