summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeff Carr <[email protected]>2025-01-08 00:51:53 -0600
committerJeff Carr <[email protected]>2025-01-08 00:51:53 -0600
commitbcabf1b3b75f86f09114116afb2636b507ededcc (patch)
treeab3d79102bba613ddc43bc3a2a1daee9003b0fdb
parentd5143b94b8527eb94e09f9c46443a2e359e1219b (diff)
move COBOL like print table into forgepb
-rw-r--r--doCommon.go4
-rw-r--r--human.go91
-rw-r--r--humanTable.go160
-rw-r--r--main.go14
-rw-r--r--windowPatches.go4
-rw-r--r--windowRepos.go2
6 files changed, 12 insertions, 263 deletions
diff --git a/doCommon.go b/doCommon.go
index 1241087..1a2a3aa 100644
--- a/doCommon.go
+++ b/doCommon.go
@@ -127,7 +127,7 @@ func doAllCheckoutDevel() bool {
me.forge = forgepb.Init()
if !IsEverythingOnDevel() {
log.Info("switching to devel branch failed")
- doHumanTable()
+ me.forge.PrintHumanTable(me.found)
badExit(nil)
return false
}
@@ -139,7 +139,7 @@ func doAllCheckoutUser() bool {
me.forge = forgepb.Init()
if !IsEverythingOnUser() {
log.Info("switching to user branch failed")
- doHumanTable()
+ me.forge.PrintHumanTable(me.found)
return false
}
return true
diff --git a/human.go b/human.go
deleted file mode 100644
index 68d2bfc..0000000
--- a/human.go
+++ /dev/null
@@ -1,91 +0,0 @@
-package main
-
-import (
- "os"
- "path/filepath"
- "time"
-
- "go.wit.com/lib/gui/shell"
- "go.wit.com/lib/protobuf/gitpb"
- "go.wit.com/log"
-)
-
-func HumanPrintRepo(check *gitpb.Repo) {
- if check == nil {
- log.Info("forge: you sent me nil")
- return
- }
-
- if check.GetTargetVersion() == "" {
- log.Info("TargetVersion == blank")
- }
- if check.GetTargetVersion() == check.GetCurrentVersion() {
- log.Info("IsReleased() == true. do not release this a second time")
- } else {
- log.Info("IsReleased() == false")
- }
- if check.CheckDirty() {
- log.Info("CheckDirty() == true. do not release dirty repos")
- } else {
- log.Info("CheckDirty() == false")
- }
- if check.GetGoPrimitive() {
- log.Info("IsPrimitive() == true")
- } else {
- log.Info("IsPrimitive() == false")
- }
- if me.forge.Config.IsPrivate(check.GetGoPath()) {
- log.Info("IsPrivate() == true")
- } else {
- log.Info("IsPrivate() == false")
- }
- if ok, compiled, err := check.IsProtobuf(); ok {
- log.Info(log.Sprint("IsProtobuf() == true compiled protobuf files = ", compiled))
- if err != nil {
- log.Info("IsProtobuf() ERROR = ", err)
- }
- for _, s := range compiled {
- log.Info("\tcompiled file found:", s)
- }
- } else {
- log.Info("IsProtobuf() == false")
- if err != nil {
- log.Info("IsProtobuf() ERROR = ", err)
- }
- }
-
- // testNext(check)
-
- me.found.AppendUniqueGoPath(check)
- doHumanTable()
-
- printTime("LastPull", check.Times.LastPull.AsTime())
- printTime("LastUpdate", check.Times.LastUpdate.AsTime())
- printTime("LastDirty", check.Times.LastDirty.AsTime())
- printTime("dir mtime", check.Times.MtimeDir.AsTime())
- printTime("HEAD mtime", check.Times.MtimeHead.AsTime())
- printTime("Index mtime", check.Times.MtimeIndex.AsTime())
- printTime("fetch", check.Times.MtimeFetch.AsTime())
- printTime("last go.sum", check.Times.LastGoDep.AsTime())
- printTime("last commit", check.Times.NewestCommit.AsTime())
-}
-
-func testGoRepo(check *gitpb.Repo) {
- data, _ := os.ReadFile(filepath.Join(check.FullPath, "go.mod"))
- log.Info(string(data))
-
- if me.forge.FinalGoDepsCheckOk(check) {
- log.Info("forge.FinalGoDepsCheck(check) worked!")
- } else {
- log.Info("forge.FinalGoDepsCheck(check) failed. boo.")
- }
-
-}
-
-func printTime(s string, t time.Time) {
- now := time.Now()
- dur := now.Sub(t)
- if dur < (time.Hour * 24) {
- log.Printf("%s mtime last changed %s\n", s, shell.FormatDuration(dur))
- }
-}
diff --git a/humanTable.go b/humanTable.go
deleted file mode 100644
index ec5890c..0000000
--- a/humanTable.go
+++ /dev/null
@@ -1,160 +0,0 @@
-package main
-
-import (
- "fmt"
-
- "go.wit.com/lib/gui/shell"
- "go.wit.com/lib/protobuf/gitpb"
- "go.wit.com/log"
-)
-
-// you can replace all of COBOL with this amount of GO
-
-// ah yes, COBOL. what an ancient throwback. for those that know
-// then you know exactly what is in this file. For those that don't, here it is:
-
-// All this does is output human readable text formatted to be viewable on
-// a console with a fixed with font. AKA: a typerwriter. Which is exactly
-// what COBOL did in the 1970's (60s? notsure) And the 80s.
-
-// So, you want to dump out stuff on the console. Let's see. Something like
-
-/*
- forge --favorites
-
- go.wit.com/apps/myapp v0.2.0 (installed)
- go.wit.com/lib/somethingfun v0.0.7 (not downloaded)
-*/
-
-// anyway, you get the idea. This is also called COBOL because it does on
-// thing and truncates every line output to the columns you see with stty -a
-// my monitor is huge, so it's not going to work at 80x24. 160x48 is better
-// actually, I'd predict some of these will probably end up 240 wide
-// long live good eyesight and 4K monitors!
-
-func doHumanTable() {
- log.DaemonMode(true)
-
- // log.Info(standardStart5("gopath", "cur name", "master", "user", "repo type"))
- log.Info(standardTable8("repopath", "cur br", "age", "target", "master", "devel", "user", "curver", "repo type"))
- all := me.found.SortByFullPath()
- for all.Scan() {
- repo := all.Next()
- sendRepoToTable(repo)
- }
-}
-
-func standardTable5(arg1, arg2, arg3, arg4, arg5 string) string {
- len1 := 40
- len2 := 12
- len3 := 12
- len4 := 16
- len5 := 8
- var s string
- if len(arg1) > len1 {
- arg1 = arg1[:len1]
- }
- s = "%-" + fmt.Sprintf("%d", len1) + "s "
- if len(arg2) > len2 {
- arg2 = arg2[:len2]
- }
- s += "%-" + fmt.Sprintf("%d", len2) + "s "
- if len(arg3) > len3 {
- arg3 = arg3[:len3]
- }
- s += "%-" + fmt.Sprintf("%d", len3) + "s "
- if len(arg4) > len4 {
- arg4 = arg4[:len4]
- }
- s += "%-" + fmt.Sprintf("%d", len4) + "s "
- if len(arg5) > len5 {
- arg5 = arg5[:len5]
- }
- s += "%-" + fmt.Sprintf("%d", len5) + "s"
- return fmt.Sprintf(s, arg1, arg2, arg3, arg4, arg5)
-}
-
-func standardTable8(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9 string) string {
- len1 := 40
- len2 := 12
- len3 := 6
- len4 := 12
- len5 := 16
- len6 := 16
- len7 := 16
- len8 := 16
- len9 := 8
- var s string
- if len(arg1) > len1 {
- arg1 = arg1[:len1]
- }
- s = "%-" + fmt.Sprintf("%d", len1) + "s "
- if len(arg2) > len2 {
- arg2 = arg2[:len2]
- }
- s += "%-" + fmt.Sprintf("%d", len2) + "s "
- if len(arg3) > len3 {
- arg3 = arg3[:len3]
- }
- s += "%-" + fmt.Sprintf("%d", len3) + "s "
- if len(arg4) > len4 {
- arg4 = arg4[:len4]
- }
- s += "%-" + fmt.Sprintf("%d", len4) + "s "
-
- if len(arg5) > len5 {
- arg5 = arg5[:len5]
- }
- s += "%-" + fmt.Sprintf("%d", len5) + "s "
-
- if len(arg6) > len6 {
- arg6 = arg6[:len6]
- }
- s += "%-" + fmt.Sprintf("%d", len6) + "s "
-
- if len(arg7) > len7 {
- arg7 = arg7[:len7]
- }
- s += "%-" + fmt.Sprintf("%d", len7) + "s "
-
- if len(arg8) > len8 {
- arg8 = arg8[:len8]
- }
- s += "%-" + fmt.Sprintf("%d", len8) + "s "
-
- if len(arg9) > len9 {
- arg9 = arg9[:len9]
- }
- s += "%-" + fmt.Sprintf("%d", len9) + "s "
-
- return fmt.Sprintf(s, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9)
-}
-
-func sendRepoToTable(repo *gitpb.Repo) {
- var end string
- if repo.IsDirty() {
- end += "(dirty) "
- }
- var mhort string = repo.GetMasterVersion()
- var dhort string = repo.GetDevelVersion()
- var uhort string = repo.GetUserVersion()
- var thort string = repo.GetTargetVersion()
- var chort string = repo.GetCurrentBranchVersion()
- var cname string = repo.GetCurrentBranchName()
-
- var gopath string = repo.GetGoPath()
- var rtype string = repo.GetRepoType()
-
- age := shell.FormatDuration(repo.NewestAge())
-
- start := standardTable8(gopath, cname, age, thort, mhort, dhort, uhort, chort, rtype)
-
- if me.forge.Config.IsReadOnly(repo.GetGoPath()) {
- end += "(readonly) "
- }
- if repo.GetMasterBranchName() != "master" && repo.GetMasterBranchName() != "main" {
- end += "(m:" + repo.GetMasterBranchName() + ") "
- }
-
- log.Info(start, end)
-}
diff --git a/main.go b/main.go
index faf49e4..d90e574 100644
--- a/main.go
+++ b/main.go
@@ -70,7 +70,7 @@ func main() {
me.forge = forgepb.Init()
me.found = new(gitpb.Repos)
argv.Checkout.User.findRepos()
- doHumanTable()
+ me.forge.PrintHumanTable(me.found)
okExit("")
}
@@ -79,7 +79,7 @@ func main() {
me.forge = forgepb.Init()
me.found = new(gitpb.Repos)
argv.Checkout.Devel.findRepos()
- doHumanTable()
+ me.forge.PrintHumanTable(me.found)
okExit("")
}
@@ -88,7 +88,7 @@ func main() {
me.forge = forgepb.Init()
me.found = new(gitpb.Repos)
argv.Checkout.Master.findRepos()
- doHumanTable()
+ me.forge.PrintHumanTable(me.found)
}
log.Info("make 'user' the default here?")
okExit("")
@@ -101,7 +101,7 @@ func main() {
doCheckDirtyAndConfigSave()
me.found = new(gitpb.Repos)
findDirty()
- doHumanTable()
+ me.forge.PrintHumanTable(me.found)
okExit("")
}
@@ -112,7 +112,7 @@ func main() {
if argv.Show != "" {
repo := me.forge.FindByGoPath(argv.Show)
- HumanPrintRepo(repo)
+ me.forge.HumanPrintRepo(repo)
okExit("")
}
@@ -131,7 +131,7 @@ func main() {
if argv.List != nil {
argv.List.findRepos()
// print out the repos
- doHumanTable()
+ me.forge.PrintHumanTable(me.found)
okExit("patches")
}
if argv.Patch != nil {
@@ -157,7 +157,7 @@ func main() {
// nothing else was specified to be done,
// then just list the table to stdout
if gui.NoGui() {
- doHumanTable()
+ me.forge.PrintHumanTable(me.found)
okExit("")
}
diff --git a/windowPatches.go b/windowPatches.go
index 0b353ab..3902444 100644
--- a/windowPatches.go
+++ b/windowPatches.go
@@ -95,7 +95,7 @@ func submitPatchesBox(box *gui.Node) *patchSummary {
}
if IsAnythingDirty() {
log.Info("You can't apply patches when repos are dirty")
- doHumanTable()
+ me.forge.PrintHumanTable(me.found)
return
}
})
@@ -112,7 +112,7 @@ func submitPatchesBox(box *gui.Node) *patchSummary {
}
if IsAnythingDirty() {
log.Info("You can't apply patches when repos are dirty")
- doHumanTable()
+ me.forge.PrintHumanTable(me.found)
return
}
applyPatchset(pset)
diff --git a/windowRepos.go b/windowRepos.go
index a507bc5..c9fb3af 100644
--- a/windowRepos.go
+++ b/windowRepos.go
@@ -115,7 +115,7 @@ func (r *repoWindow) repoMenu() *gui.Node {
r.Disable()
if IsAnythingDirty() {
log.Info("You can't apply patches when repos are dirty")
- doHumanTable()
+ me.forge.PrintHumanTable(me.found)
return
}
if !r.mergeAllUserToDevel() {