summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeff Carr <[email protected]>2025-10-04 03:45:49 -0500
committerJeff Carr <[email protected]>2025-10-04 03:45:49 -0500
commit8d535b0a0771ceb53a4163226b1d7d5f95052989 (patch)
treefdbef32a60674ea185024c8aba37fac836cce528
parent5ee8c4f295205e7bfd316b43a503f1ec281a1b03 (diff)
start removing old table codev0.0.163
-rw-r--r--config.common.go22
-rw-r--r--human.go37
-rw-r--r--humanTable.go25
-rw-r--r--tableDefault.go104
-rw-r--r--tablePull.go45
5 files changed, 164 insertions, 69 deletions
diff --git a/config.common.go b/config.common.go
index ff70e08..925b2de 100644
--- a/config.common.go
+++ b/config.common.go
@@ -22,19 +22,19 @@ import (
"go.wit.com/lib/protobuf/gitpb"
)
-/*
-func (all *ForgeConfigs) UpdateGoPath(name string, gopath string) bool {
- oldr := all.DeleteByGoPath(name)
- if oldr == nil {
- // nothing to update
- return false
+// move away from IsReadOnly. Only use repo.Namespace
+func (f *Forge) IsWritable(repo *gitpb.Repo) bool {
+ if f.Config.IsWritable(repo.Namespace) {
+ return true
}
-
- // update gopath and append it back to the list
- oldr.GoPath = gopath
- return all.Append(oldr)
+ if f.Config.IsWritable(repo.FullPath) {
+ return true
+ }
+ if !f.Config.IsWritable(repo.GetGoPath()) {
+ return true
+ }
+ return false
}
-*/
// returns true if gopath is readonly()
// will attempt to match IsWritable("foo") against anything ending in "foo"
diff --git a/human.go b/human.go
index 1d3bff8..f58e23e 100644
--- a/human.go
+++ b/human.go
@@ -4,7 +4,6 @@ package forgepb
import (
"fmt"
- "path/filepath"
"go.wit.com/lib/gui/shell"
"go.wit.com/lib/protobuf/gitpb"
@@ -114,39 +113,3 @@ func (f *Forge) PrintReleaseReport(repos *gitpb.Repos) int {
log.Info(fmt.Sprintf("total repo count = %d", count))
return count
}
-
-func (f *Forge) PrintPullTable(all *gitpb.Repos) {
- tablePB := f.makePullTable(all)
- tablePB.PrintTable()
-}
-
-func (f *Forge) makePullTable(pb *gitpb.Repos) *gitpb.ReposTable {
- t := pb.NewTable("pullTable")
- t.NewUuid()
-
- var col *gitpb.RepoFunc
- // var col int
-
- col = t.AddMasterBranchName()
- col.Width = 10
-
- col = t.AddMasterVersion()
- // col.SetTitle("mver")
- col.Width = 15
-
- col = t.AddStringFunc("blah", func(r *gitpb.Repo) string {
- _, base := filepath.Split(r.Namespace)
- return base
- })
- col.Width = 9
-
- col = t.AddDevelVersion()
- col.Width = 15
-
- col = t.AddNamespace()
- col.Width = 18
-
- col = t.AddFullPath()
- col.Width = -1
- return t
-}
diff --git a/humanTable.go b/humanTable.go
index 9532170..748475b 100644
--- a/humanTable.go
+++ b/humanTable.go
@@ -2,18 +2,10 @@
package forgepb
-import (
- "path/filepath"
-
- "go.wit.com/lib/cobol"
- "go.wit.com/lib/gui/shell"
- "go.wit.com/lib/protobuf/gitpb"
- "go.wit.com/log"
-)
-
// All this does is output human readable text formatted to be viewable on
// a console with a fixed with font. AKA: a typerwriter
+/*
func (f *Forge) PrintHumanTable(allr *gitpb.Repos) {
log.DaemonMode(true)
@@ -126,18 +118,8 @@ func (f *Forge) printRepoToTable(repo *gitpb.Repo, sizes []int, full bool) {
if gopath == "" {
gopath = repo.GetFullPath()
}
- 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"
- }
+
+ rtype := f.getRepoType(repo)
// ctime := repo.Tags.GetAge(mhort)
// age := shell.FormatDuration(time.Since(ctime))
@@ -226,3 +208,4 @@ func (f *Forge) printForgedToTable(repo *gitpb.Repo, sizes []int) {
log.Info(cobol.TerminalChomp(start + " " + end))
}
+*/
diff --git a/tableDefault.go b/tableDefault.go
new file mode 100644
index 0000000..2cb8f9a
--- /dev/null
+++ b/tableDefault.go
@@ -0,0 +1,104 @@
+// Copyright 2025 WIT.COM Inc Licensed GPL 3.0
+
+package forgepb
+
+import (
+ "go.wit.com/lib/gui/shell"
+ "go.wit.com/lib/protobuf/gitpb"
+)
+
+// this is the default table layout for repos in forge
+
+func (f *Forge) PrintDefaultTB(pb *gitpb.Repos) {
+ tablePB := f.makeDefaultTB(pb)
+ tablePB.PrintTable()
+}
+
+func (f *Forge) getRepoType(repo *gitpb.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 (f *Forge) makeDefaultTB(pb *gitpb.Repos) *gitpb.ReposTable {
+ t := pb.NewTable("forgedList")
+ t.NewUuid()
+
+ var col *gitpb.RepoFunc
+
+ col = t.AddNamespace()
+ col.Width = 33
+
+ col = t.AddCurrentBranchName()
+ col.Width = 7
+ col.Header.Name = "current"
+
+ col = t.AddStringFunc("age", func(r *gitpb.Repo) string {
+ if r.IsDirty() {
+ return ""
+ }
+ dur := r.NewestAge()
+ return shell.FormatDuration(dur)
+ })
+ col.Width = 3
+
+ col = t.AddStringFunc("user", func(r *gitpb.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 *gitpb.Repo) string {
+ return f.getRepoType(r)
+ })
+ col.Width = 6
+
+ col = t.AddStringFunc("r/w", func(r *gitpb.Repo) string {
+ if f.IsWritable(r) {
+ return "rw"
+ }
+ return ""
+ })
+ col.Width = 3
+
+ col = t.AddURL()
+ col.Width = 42
+
+ col = t.AddState()
+ col.Width = -1
+ return t
+}
+
+// // the old function names
+func (f *Forge) PrintHumanTable(pb *gitpb.Repos) {
+ f.PrintDefaultTB(pb)
+}
+
+func (f *Forge) PrintHumanTableFull(pb *gitpb.Repos) {
+ f.PrintDefaultTB(pb)
+}
+
+func (f *Forge) PrintHumanTableDirty(pb *gitpb.Repos) {
+ f.PrintDefaultTB(pb)
+}
diff --git a/tablePull.go b/tablePull.go
new file mode 100644
index 0000000..8e0a282
--- /dev/null
+++ b/tablePull.go
@@ -0,0 +1,45 @@
+// Copyright 2025 WIT.COM Inc Licensed GPL 3.0
+
+package forgepb
+
+import (
+ "path/filepath"
+
+ "go.wit.com/lib/protobuf/gitpb"
+)
+
+func (f *Forge) PrintPullTable(all *gitpb.Repos) {
+ tablePB := f.makePullTable(all)
+ tablePB.PrintTable()
+}
+
+func (f *Forge) makePullTable(pb *gitpb.Repos) *gitpb.ReposTable {
+ t := pb.NewTable("pullTable")
+ t.NewUuid()
+
+ var col *gitpb.RepoFunc
+ // var col int
+
+ col = t.AddMasterBranchName()
+ col.Width = 10
+
+ col = t.AddMasterVersion()
+ // col.SetTitle("mver")
+ col.Width = 15
+
+ col = t.AddStringFunc("blah", func(r *gitpb.Repo) string {
+ _, base := filepath.Split(r.Namespace)
+ return base
+ })
+ col.Width = 9
+
+ col = t.AddDevelVersion()
+ col.Width = 15
+
+ col = t.AddNamespace()
+ col.Width = 18
+
+ col = t.AddFullPath()
+ col.Width = -1
+ return t
+}