From 076bdfb9c65880cc9744d30d8e084ec2f278a457 Mon Sep 17 00:00:00 2001 From: Jeff Carr Date: Thu, 4 Sep 2025 10:25:26 -0500 Subject: [PATCH] use standard table code. start labeling private repos --- configLookup.go | 13 +++++++++++++ humanTable.go | 30 ++++++++++++++++++++++-------- 2 files changed, 35 insertions(+), 8 deletions(-) diff --git a/configLookup.go b/configLookup.go index e829091..5a230a8 100644 --- a/configLookup.go +++ b/configLookup.go @@ -18,6 +18,8 @@ package forgepb import ( "path/filepath" "strings" + + "go.wit.com/lib/protobuf/gitpb" ) /* @@ -116,6 +118,17 @@ func (fc *ForgeConfigs) DebName(gopath string) string { return normalBase } +// a work in progress +func (f *Forge) IsPrivate(repo *gitpb.Repo) bool { + namespace := repo.GetNamespace() + if namespace == "" { + // assume true + return true + } + + return f.Config.IsPrivate(namespace) +} + // is this a non-publishable repo? // matches package names from apt // diff --git a/humanTable.go b/humanTable.go index 612e789..d70baf1 100644 --- a/humanTable.go +++ b/humanTable.go @@ -3,7 +3,6 @@ package forgepb import ( - "fmt" "path/filepath" "go.wit.com/lib/cobol" @@ -44,7 +43,7 @@ func (f *Forge) PrintHumanTable(allr *gitpb.Repos) { // print the header args := []string{"namespace", "cur br", "age", "master", "devel", "user", "", "lasttag", "next", "repo type"} sizes := []int{40, 9, 6, 16, 16, 16, 1, 12, 12, 8} - log.Info(cobol.TerminalChomp(standardTableSize10(sizes, args))) + log.Info(cobol.TerminalChomp(cobol.StandardTableSize10(sizes, args))) all := allr.SortByFullPath() for all.Scan() { @@ -63,7 +62,7 @@ func (f *Forge) PrintForgedTable(allr *gitpb.Repos) { // print the header args := []string{"namespace", "cur br", "age", "master", "devel", "last tag", "", "", "", ""} sizes := []int{40, 9, 6, 12, 16, 16, 16, 12, 12, 8} - log.Info(cobol.TerminalChomp(standardTableSize10(sizes, args))) + log.Info(cobol.TerminalChomp(cobol.StandardTableSize10(sizes, args))) all := allr.SortByFullPath() for all.Scan() { @@ -82,7 +81,7 @@ func (f *Forge) PrintHumanTableFull(allr *gitpb.Repos) { // print the header args := []string{"cur br", "age", "master", "devel", "user", "", "lasttag", "next", "repo type", "namespace"} sizes := []int{9, 6, 16, 16, 16, 1, 12, 12, 8, 0} - log.Info(cobol.TerminalChomp(standardTableSize10(sizes, args))) + log.Info(cobol.TerminalChomp(cobol.StandardTableSize10(sizes, args))) all := allr.SortByFullPath() for all.Scan() { @@ -102,7 +101,7 @@ func (f *Forge) PrintHumanTableDirty(allr *gitpb.Repos) { // print the header args := []string{"namespace", "cur br", "age", "master", "devel", "user", "", "lasttag", "next", "repo type"} sizes := []int{40, 9, 6, 16, 16, 16, 1, 12, 12, 8} - log.Info(cobol.TerminalChomp(standardTableSize10(sizes, args))) + log.Info(cobol.TerminalChomp(cobol.StandardTableSize10(sizes, args))) for repo := range allr.IterAll() { f.printRepoToTable(repo, sizes, false) @@ -147,6 +146,7 @@ func tallyBranchTotals(t *tally, repo *gitpb.Repo) { t.unknown += 1 } +/* func standardTable5(arg1, arg2, arg3, arg4, arg5 string) string { len1 := 40 len2 := 12 @@ -176,7 +176,9 @@ func standardTable5(arg1, arg2, arg3, arg4, arg5 string) string { s += "%-" + fmt.Sprintf("%d", len5) + "s" return fmt.Sprintf(s, arg1, arg2, arg3, arg4, arg5) } +*/ +/* func standardTableSize10(sizes []int, args []string) string { var s string for i, si := range sizes { @@ -204,6 +206,7 @@ func standardTableSize10(sizes []int, args []string) string { return fmt.Sprintf(s, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10) // return fmt.Sprintf(s, args) } +*/ func (f *Forge) printRepoToTable(repo *gitpb.Repo, sizes []int, full bool) { var end string @@ -226,6 +229,17 @@ func (f *Forge) printRepoToTable(repo *gitpb.Repo, sizes []int, full bool) { 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" + } // ctime := repo.Tags.GetAge(mhort) // age := shell.FormatDuration(time.Since(ctime)) @@ -248,7 +262,7 @@ func (f *Forge) printRepoToTable(repo *gitpb.Repo, sizes []int, full bool) { } else { args = []string{gopath, cname, age, mhort, dhort, uhort, chort, lasttag, thort, rtype} } - start := standardTableSize10(sizes, args) + start := cobol.StandardTableSize10(sizes, args) if rtype == "protobuf" { if repo.GoInfo.GoBinary { @@ -307,7 +321,7 @@ func (f *Forge) printForgedToTable(repo *gitpb.Repo, sizes []int) { var args []string args = []string{ns, cname, age, mhort, dhort, lasttag, "", "", "", ""} - start := standardTableSize10(sizes, args) + start := cobol.StandardTableSize10(sizes, args) end += "todo" @@ -323,7 +337,7 @@ func (psets *Patchsets) PrintTable() { // print the header args := []string{"commit hash", "new hash", "", "", "name", "Repo Namespace", "", "", "", "", ""} sizes := []int{12, 12, 3, 3, 40, 80, 2, 2, 2, 2} - log.Info(cobol.TerminalChomp(standardTableSize10(sizes, args))) + log.Info(cobol.TerminalChomp(cobol.StandardTableSize10(sizes, args))) var countCONTENTS int var countPARTS int