summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gitTag.common.go16
-rw-r--r--tableMissing.go105
2 files changed, 120 insertions, 1 deletions
diff --git a/gitTag.common.go b/gitTag.common.go
index 635ca7d..66e45e9 100644
--- a/gitTag.common.go
+++ b/gitTag.common.go
@@ -144,6 +144,22 @@ func (repo *Repo) IsLocalBranch(findname string) bool {
return false
}
+func (repo *Repo) IsLocalBranchVerbose(findname string) bool {
+ for t := range repo.Tags.IterAll() {
+ if !strings.HasPrefix(t.Refname, "refs/heads") {
+ continue
+ }
+ path, filename := filepath.Split(t.Refname)
+ log.Info("gitpb.IsBranch() tag:", path, filename, "from", repo.GetGoPath())
+ if filename == findname {
+ log.Info("gitpb.IsBranch() found tag:", path, filename, "from", repo.GetGoPath())
+ return true
+ }
+ }
+ log.Info("did not find tag:", findname, "in", repo.GetGoPath())
+ return false
+}
+
func (repo *Repo) IsRemoteBranch(findname string) bool {
for t := range repo.Tags.IterAll() {
if !strings.HasPrefix(t.Refname, "refs/remotes/origin") {
diff --git a/tableMissing.go b/tableMissing.go
index bf3c2bc..fe729dd 100644
--- a/tableMissing.go
+++ b/tableMissing.go
@@ -2,6 +2,11 @@
package gitpb
+import (
+ "go.wit.com/lib/gui/shell"
+ "go.wit.com/log"
+)
+
func (pb *Repos) PrintMissingTable() {
t := pb.NewTable("missing repos table")
t.NewUuid()
@@ -15,7 +20,7 @@ func (pb *Repos) PrintMissingTable() {
col.Width = -1
/*
- col = t.AddStringFunc("hash", func(r *gitpb.Repo) string {
+ col = t.AddStringFunc("hash", func(r *Repo) string {
if r.Tags == nil {
return "nil"
}
@@ -28,3 +33,101 @@ func (pb *Repos) PrintMissingTable() {
*/
t.PrintTable()
}
+
+func getRepoType(repo *Repo) string {
+ var rtype string = repo.GetRepoType()
+ switch rtype {
+ case "binary":
+ rtype = "GO bin"
+ case "library":
+ rtype = "GO lib"
+ case "protobuf":
+ rtype = "GO pb"
+ }
+ // if f.IsPrivate(repo) {
+ // rtype = "priv"
+ // }
+ return rtype
+}
+
+func (pb *Repos) PrintDefaultTB() string {
+ tablePB := pb.MakeDefaultTB()
+ tablePB.PrintTable()
+ var dirty int
+ // var writable int // need forge to determine this
+ var bins int
+ var protos int
+ for repo := range pb.IterAll() {
+ if repo.IsDirty() {
+ dirty += 1
+ }
+ if repo.IsBinary() {
+ bins += 1
+ }
+ if repo.IsProtobuf() {
+ protos += 1
+ }
+ }
+ return log.Sprintf("gitpb.DefaultRepos: total=(%d) dirty=(%d) binaries=(%d) protobufs(%d)", pb.Len(), dirty, bins, protos)
+}
+func (pb *Repos) MakeDefaultTB() *ReposTable {
+ t := pb.NewTable("gitpb Default Table")
+ t.NewUuid()
+
+ var col *RepoFunc
+
+ col = t.AddNamespace()
+ col.Width = 33
+
+ col = t.AddCurrentBranchName()
+ col.Width = 7
+ col.Header.Name = "current"
+
+ col = t.AddStringFunc("age", func(r *Repo) string {
+ if r.IsDirty() {
+ return ""
+ }
+ dur := r.NewestAge()
+ return shell.FormatDuration(dur)
+ })
+ col.Width = 3
+
+ col = t.AddStringFunc("user", func(r *Repo) string {
+ ver := r.GetUserVersion()
+ if r.IsDirty() {
+ ver = "* " + ver
+ }
+ return ver
+ })
+ col.Width = 14
+
+ col = t.AddDevelVersion()
+ col.Width = 12
+ col.Header.Name = "devel"
+
+ col = t.AddMasterVersion()
+ col.Width = 12
+ col.Header.Name = "master"
+
+ col = t.AddStringFunc("type", func(r *Repo) string {
+ return getRepoType(r)
+ })
+ col.Width = 6
+
+ /*
+ col = t.AddStringFunc("r/w", func(r *Repo) string {
+ if f.IsWritable(r) {
+ return "rw"
+ }
+ return ""
+ })
+ col.Width = 3
+ */
+
+ col = t.AddState()
+ col.Width = 12
+
+ col = t.AddURL()
+ col.Width = 42
+ return t
+}