package main import ( "fmt" "os" "go.wit.com/lib/protobuf/gitpb" "go.wit.com/log" ) func list() { log.DaemonMode(true) if argv.ListConf { me.forge.ConfigPrintTable() os.Exit(0) } if argv.List { repos := me.forge.Repos.SortByGoPath() for repos.Scan() { repo := repos.Next() verifyPrint(repo) } 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) { 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) } if me.forge.IsReadOnly(repo.GoPath) && ! argv.ReadOnly { return } 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() { return false } s["gopath"] = repo.GetGoPath() s["rtype"] = repo.RepoType() 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 } s["dname"] = repo.GetDevelBranchName() if s["dname"] == "" { log.Info("verify() no devel branch name") return false } s["uname"] = repo.GetUserBranchName() if s["uname"] == "" { log.Info("verify() no user branch name") return false } s["cname"] = repo.GetCurrentBranchName() s["mver"] = repo.GetMasterVersion() s["dver"] = repo.GetDevelVersion() s["uver"] = repo.GetUserVersion() s["cver"] = repo.GetCurrentBranchVersion() return true }