summaryrefslogtreecommitdiff
path: root/list.go
diff options
context:
space:
mode:
authorJeff Carr <[email protected]>2024-12-03 00:33:17 -0600
committerJeff Carr <[email protected]>2024-12-03 00:33:17 -0600
commit659bed891bc1aff56bc87e2de663fb63d2b1b81a (patch)
treeef294fe40fb329edb4737148167da77f5d0663a8 /list.go
parent10193b77f2e25cffaf37b7d3d287506a210d29ed (diff)
start making this tool useful
Diffstat (limited to 'list.go')
-rw-r--r--list.go81
1 files changed, 24 insertions, 57 deletions
diff --git a/list.go b/list.go
index e475d95..e9f9476 100644
--- a/list.go
+++ b/list.go
@@ -9,6 +9,7 @@ import (
)
func list() {
+ log.DaemonMode(true)
if argv.ListConf {
me.forge.ConfigPrintTable()
os.Exit(0)
@@ -18,24 +19,7 @@ func list() {
repos := me.forge.Repos.SortByGoPath()
for repos.Scan() {
repo := repos.Next()
- var end string
- if repo.CheckDirty() {
- end += "(dirty) "
- }
- s := make(map[string]string)
- if !verify(repo, s) {
- log.Info("going to delete", repo.GoPath)
- if argv.Real {
- me.forge.Repos.DeleteByGoPath(repo.GetGoPath())
- me.forge.Repos.ConfigSave()
- } else {
- log.Info("need argv --real to delete", repo.GoPath)
- }
- os.Exit(0)
- }
- start := fmt.Sprintf("%-50s %-8s %-10s %-10s %-10s %-10s", s["gopath"], s["rtype"], s["mver"], s["dver"], s["uver"], s["cver"])
- end += fmt.Sprintf("(%s,%s,%s,%s) ", s["mname"], s["dname"], s["uname"], s["cname"])
- log.Info(start, end)
+ verifyPrint(repo)
}
os.Exit(0)
}
@@ -51,51 +35,32 @@ func list() {
}
}
-func whichOne(repo *gitpb.Repo, a map[string]any, hmm string) any {
- return nil
-}
-
-func updateRepo(repo *gitpb.Repo, a map[string]any) bool {
- return false
-}
-
-func Delete(repo *gitpb.Repo, s map[string]string) bool {
- if repo.Published == nil {
- log.Info("published is nil", repo.Published)
- } else {
- log.Info("published len", repo.Published.Len())
+func verifyPrint(repo *gitpb.Repo) {
+ var end string
+ if repo.CheckDirty() {
+ end += "(dirty) "
}
-
- // add a new one here
- newr := gitpb.Repo{
- FullPath: repo.FullPath,
- GoPath: repo.GoPath,
- URL: repo.URL,
- Tags: repo.Tags,
- LastPull: repo.LastPull,
- MasterBranchName: repo.MasterBranchName,
- DevelBranchName: repo.DevelBranchName,
- UserBranchName: repo.UserBranchName,
- GoLibrary: repo.GoLibrary,
- GoBinary: repo.GoBinary,
- GoPrimitive: repo.GoPrimitive,
- GoPlugin: repo.GoPlugin,
- GoDeps: repo.GoDeps,
- LastGoDep: repo.LastGoDep,
- Dirty: repo.Dirty,
- Published: repo.Published,
- TargetVersion: repo.TargetVersion,
- ReadOnly: repo.ReadOnly,
- GoProtobuf: repo.GoProtobuf,
+ s := make(map[string]string)
+ if !verify(repo, s) {
+ log.Info("going to delete", repo.GoPath)
+ if argv.Real {
+ me.forge.Repos.DeleteByGoPath(repo.GetGoPath())
+ me.forge.Repos.ConfigSave()
+ } else {
+ log.Info("need argv --real to delete", repo.GoPath)
+ }
+ os.Exit(0)
}
- if argv.Real {
- me.forge.Repos.AppendUniqueGoPath(&newr)
+ if me.forge.IsReadOnly(repo.GoPath) && ! argv.ReadOnly {
+ return
}
- return true
+ start := fmt.Sprintf("%-40s %-8s %-10s %-10s %-10s %-10s", s["gopath"], s["rtype"], s["mver"], s["dver"], s["uver"], s["cver"])
+ end += fmt.Sprintf("(%s,%s,%s,%s) ", s["mname"], s["dname"], s["uname"], s["cname"])
+ log.Info(start, end)
}
func verify(repo *gitpb.Repo, s map[string]string) bool {
- if ! repo.IsValid() {
+ if !repo.IsValid() {
return false
}
s["gopath"] = repo.GetGoPath()
@@ -104,10 +69,12 @@ func verify(repo *gitpb.Repo, s map[string]string) bool {
s["mname"] = repo.GetMasterBranchName()
if s["mname"] == "" {
log.Info("verify() no master branch name")
+ s["mver"] = repo.GetMasterVersion()
return false
}
// only verify the master branch name with read-only repos
if me.forge.IsReadOnly(repo.GoPath) {
+ s["mver"] = repo.GetMasterVersion()
return true
}