summaryrefslogtreecommitdiff
path: root/tableReposDefault.go
diff options
context:
space:
mode:
authorJeff Carr <[email protected]>2025-10-17 04:06:50 -0500
committerJeff Carr <[email protected]>2025-10-17 04:06:50 -0500
commit3029cd72c4964c656ae6b5baf202d5b81cd97b0a (patch)
tree554345b9d720fcf00d115a8bb7a1baf5b9c89dc1 /tableReposDefault.go
parent9a0089928e713a35b4a5c0ab46b86fd1a2e498da (diff)
cleaned names up
Diffstat (limited to 'tableReposDefault.go')
-rw-r--r--tableReposDefault.go111
1 files changed, 111 insertions, 0 deletions
diff --git a/tableReposDefault.go b/tableReposDefault.go
new file mode 100644
index 0000000..362bb02
--- /dev/null
+++ b/tableReposDefault.go
@@ -0,0 +1,111 @@
+// Copyright 2025 WIT.COM Inc Licensed GPL 3.0
+
+package gitpb
+
+import (
+ "go.wit.com/lib/gui/shell"
+ "go.wit.com/log"
+)
+
+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.AddLastTag()
+ col.Width = 12
+ col.Header.Name = "lasttag"
+
+ 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.AddURL()
+ col.Width = 20
+
+ col = t.AddState()
+ col.Width = -1
+
+ return t
+}
+
+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
+}