From 952334bf58e49e381171e2c71e20a847f4138df6 Mon Sep 17 00:00:00 2001 From: Jeff Carr Date: Sun, 5 Oct 2025 03:55:22 -0500 Subject: code cleanups. old non-protobuf code almost gone --- config.common.go | 12 +++++------ human.go | 2 ++ humanBuildTable.go | 52 ---------------------------------------------- humanForgedTable.go | 60 ----------------------------------------------------- tableBuild.go | 52 ++++++++++++++++++++++++++++++++++++++++++++++ tableDefault.go | 6 +++--- tableForged.go | 60 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 7 files changed, 123 insertions(+), 121 deletions(-) delete mode 100644 humanBuildTable.go delete mode 100644 humanForgedTable.go create mode 100644 tableBuild.go create mode 100644 tableForged.go diff --git a/config.common.go b/config.common.go index 925b2de..43cd763 100644 --- a/config.common.go +++ b/config.common.go @@ -27,12 +27,12 @@ func (f *Forge) IsWritable(repo *gitpb.Repo) bool { if f.Config.IsWritable(repo.Namespace) { return true } - if f.Config.IsWritable(repo.FullPath) { - return true - } - if !f.Config.IsWritable(repo.GetGoPath()) { - return true - } + // if f.Config.IsWritable(repo.FullPath) { + // return true + // } + // if !f.Config.IsWritable(repo.GetGoPath()) { + // return true + // } return false } diff --git a/human.go b/human.go index f58e23e..e5ce98d 100644 --- a/human.go +++ b/human.go @@ -10,6 +10,8 @@ import ( "go.wit.com/log" ) +// OLD STUFF. REMOVE. USE PROTOBUF TABLES + // mostly just functions related to making STDOUT // more readable by us humans diff --git a/humanBuildTable.go b/humanBuildTable.go deleted file mode 100644 index 99f08cb..0000000 --- a/humanBuildTable.go +++ /dev/null @@ -1,52 +0,0 @@ -// Copyright 2025 WIT.COM Inc Licensed GPL 3.0 - -package forgepb - -import ( - "go.wit.com/lib/protobuf/gitpb" -) - -// returns -func (f *Forge) GetPackageVersion(repo *gitpb.Repo) string { - var s string - - s = repo.GetCurrentBranchVersion() - if repo.IsDirty() { - s += "-dirty" - } - return s -} - -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) GetBuildBaseTB(pb *gitpb.Repos) *gitpb.ReposTable { - t := pb.NewTable(".deb details") - t.NewUuid() - - var col *gitpb.RepoFunc - - col = t.AddStringFunc("Build Version", func(r *gitpb.Repo) string { - return f.GetPackageVersion(r) - }) - col.Width = 24 - - col = t.AddStringFunc("RepoType", func(r *gitpb.Repo) string { - return f.GetRepoType(r) - }) - col.Width = 8 - return t -} diff --git a/humanForgedTable.go b/humanForgedTable.go deleted file mode 100644 index 19d0818..0000000 --- a/humanForgedTable.go +++ /dev/null @@ -1,60 +0,0 @@ -// Copyright 2025 WIT.COM Inc Licensed GPL 3.0 - -package forgepb - -import ( - "go.wit.com/lib/protobuf/gitpb" -) - -func (f *Forge) PrintForgedTable(pb *gitpb.Repos) { - tablePB := f.makeForgedTable(pb) - tablePB.PrintTable() -} - -func (f *Forge) makeForgedTable(pb *gitpb.Repos) *gitpb.ReposTable { - t := pb.NewTable("forgedList") - t.NewUuid() - - var col *gitpb.RepoFunc - - col = t.AddMasterBranchName() - col.Width = 3 - - col = t.AddMasterVersion() - col.Width = 10 - - col = t.AddStringFunc("hash", func(r *gitpb.Repo) string { - if r.Tags == nil { - return "nil" - } - if r.Tags.Master == nil { - return "nil" - } - return r.Tags.Master.Hash - }) - col.Width = 6 - - col = t.AddDevelBranchName() - col.Width = 3 - - col = t.AddDevelVersion() - col.Width = 10 - - col = t.AddStringFunc("hash", func(r *gitpb.Repo) string { - if r.Tags == nil { - return "nil" - } - if r.Tags.Devel == nil { - return "nil" - } - return r.Tags.Devel.Hash - }) - col.Width = 6 - - col = t.AddNamespace() - col.Width = 42 - - col = t.AddURL() - col.Width = -1 - return t -} diff --git a/tableBuild.go b/tableBuild.go new file mode 100644 index 0000000..99f08cb --- /dev/null +++ b/tableBuild.go @@ -0,0 +1,52 @@ +// Copyright 2025 WIT.COM Inc Licensed GPL 3.0 + +package forgepb + +import ( + "go.wit.com/lib/protobuf/gitpb" +) + +// returns +func (f *Forge) GetPackageVersion(repo *gitpb.Repo) string { + var s string + + s = repo.GetCurrentBranchVersion() + if repo.IsDirty() { + s += "-dirty" + } + return s +} + +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) GetBuildBaseTB(pb *gitpb.Repos) *gitpb.ReposTable { + t := pb.NewTable(".deb details") + t.NewUuid() + + var col *gitpb.RepoFunc + + col = t.AddStringFunc("Build Version", func(r *gitpb.Repo) string { + return f.GetPackageVersion(r) + }) + col.Width = 24 + + col = t.AddStringFunc("RepoType", func(r *gitpb.Repo) string { + return f.GetRepoType(r) + }) + col.Width = 8 + return t +} diff --git a/tableDefault.go b/tableDefault.go index 2cb8f9a..823fa98 100644 --- a/tableDefault.go +++ b/tableDefault.go @@ -82,11 +82,11 @@ func (f *Forge) makeDefaultTB(pb *gitpb.Repos) *gitpb.ReposTable { }) col.Width = 3 + col = t.AddState() + col.Width = 12 + col = t.AddURL() col.Width = 42 - - col = t.AddState() - col.Width = -1 return t } diff --git a/tableForged.go b/tableForged.go new file mode 100644 index 0000000..19d0818 --- /dev/null +++ b/tableForged.go @@ -0,0 +1,60 @@ +// Copyright 2025 WIT.COM Inc Licensed GPL 3.0 + +package forgepb + +import ( + "go.wit.com/lib/protobuf/gitpb" +) + +func (f *Forge) PrintForgedTable(pb *gitpb.Repos) { + tablePB := f.makeForgedTable(pb) + tablePB.PrintTable() +} + +func (f *Forge) makeForgedTable(pb *gitpb.Repos) *gitpb.ReposTable { + t := pb.NewTable("forgedList") + t.NewUuid() + + var col *gitpb.RepoFunc + + col = t.AddMasterBranchName() + col.Width = 3 + + col = t.AddMasterVersion() + col.Width = 10 + + col = t.AddStringFunc("hash", func(r *gitpb.Repo) string { + if r.Tags == nil { + return "nil" + } + if r.Tags.Master == nil { + return "nil" + } + return r.Tags.Master.Hash + }) + col.Width = 6 + + col = t.AddDevelBranchName() + col.Width = 3 + + col = t.AddDevelVersion() + col.Width = 10 + + col = t.AddStringFunc("hash", func(r *gitpb.Repo) string { + if r.Tags == nil { + return "nil" + } + if r.Tags.Devel == nil { + return "nil" + } + return r.Tags.Devel.Hash + }) + col.Width = 6 + + col = t.AddNamespace() + col.Width = 42 + + col = t.AddURL() + col.Width = -1 + return t +} -- cgit v1.2.3