diff options
| author | Jeff Carr <[email protected]> | 2025-10-05 02:26:33 -0500 |
|---|---|---|
| committer | Jeff Carr <[email protected]> | 2025-10-05 02:26:33 -0500 |
| commit | 8d50f01597cde8c7ae0fd451347d93196b97f900 (patch) | |
| tree | 0f1ee1b7d7eb18bf83f40c5b2d041d2a842bfac2 | |
| parent | cfdbd6d6634659deb4c71b5baaacd862b11486df (diff) | |
gonev0.0.165
| -rw-r--r-- | config.go | 2 | ||||
| -rw-r--r-- | humanTable.go | 211 |
2 files changed, 1 insertions, 212 deletions
@@ -85,7 +85,7 @@ func (cfg *ForgeConfigs) DumpPB() { if cfg.GoWork { log.Infof("Config.GoWork = %v\n", cfg.GoWork) } - if cfg.Mode != ForgeMode_UNKNOWN { + if cfg.Mode != ForgeMode_NEWUSER { log.Infof("Config.Mode = %s\n", cfg.Mode) } // log.Infof("ConfigCfgPB.Hostname=%s\n", cfg.Hostname) diff --git a/humanTable.go b/humanTable.go deleted file mode 100644 index 748475b..0000000 --- a/humanTable.go +++ /dev/null @@ -1,211 +0,0 @@ -// Copyright 2025 WIT.COM Inc Licensed GPL 3.0 - -package forgepb - -// 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) - - t := new(tally) - - // print the header - args := []string{"Namespace", "branch", "age", "user", "devel", "master", "", "lasttag", "next", "repo type"} - sizes := []int{35, 9, 4, 13, 13, 13, 1, 12, 12, 8} - log.Info(cobol.TerminalChomp(cobol.StandardTableSize10(sizes, args))) - - all := allr.SortByFullPath() - for all.Scan() { - repo := all.Next() - f.printRepoToTable(repo, sizes, false) - tallyBranchTotals(t, repo) - } - log.Infof("Total repositories: %d (%d master) (%d devel) (%d user) (%d unknown)\n", t.total, t.master, t.devel, t.user, t.unknown) -} - -func (f *Forge) PrintHumanTableFull(allr *gitpb.Repos) { - log.DaemonMode(true) - - t := new(tally) - - // print the header - args := []string{"branch", "age", "user", "devel", "master", "", "lasttag", "next", "repo type", "Namespace"} - sizes := []int{9, 4, 13, 13, 13, 1, 12, 12, 8, 0} - log.Info(cobol.TerminalChomp(cobol.StandardTableSize10(sizes, args))) - - all := allr.SortByFullPath() - for all.Scan() { - repo := all.Next() - f.printRepoToTable(repo, sizes, true) - tallyBranchTotals(t, repo) - } - log.Infof("Total repositories: %d (%d user) (%d devel) (%d master) (%d unknown)\n", t.total, t.user, t.devel, t.master, t.unknown) -} - -// also shows which files are dirty -func (f *Forge) PrintHumanTableDirty(allr *gitpb.Repos) { - log.DaemonMode(true) - - t := new(tally) - - // print the header - args := []string{"Namespace", "branch", "age", "user", "devel", "master", "", "lasttag", "next", "repo type"} - sizes := []int{35, 9, 4, 13, 13, 13, 1, 12, 12, 8} - log.Info(cobol.TerminalChomp(cobol.StandardTableSize10(sizes, args))) - - for repo := range allr.IterAll() { - f.printRepoToTable(repo, sizes, false) - if len(repo.DirtyList) != 0 { - for _, line := range repo.DirtyList { - log.Info(cobol.TerminalChomp("\t" + line)) - } - } - var mver string = repo.GetMasterVersion() - repo.Tags.GetAge(mver) - - tallyBranchTotals(t, repo) - } - log.Infof("Total repositories: %d (%d user) (%d devel) (%d master) (%d unknown)\n", t.total, t.user, t.devel, t.master, t.unknown) -} - -// used to count which repos are on which branches (master/main, devel, user) -type tally struct { - total int - master int - devel int - user int - unknown int -} - -func tallyBranchTotals(t *tally, repo *gitpb.Repo) { - t.total += 1 - - if repo.GetCurrentBranchName() == repo.GetMasterBranchName() { - t.master += 1 - return - } - if repo.GetCurrentBranchName() == repo.GetDevelBranchName() { - t.devel += 1 - return - } - if repo.GetCurrentBranchName() == repo.GetUserBranchName() { - t.user += 1 - return - } - log.Printf("unknown curr=%s user=%s devel=%s master=%s\n", repo.GetCurrentBranchName(), repo.GetUserBranchName(), repo.GetDevelBranchName(), repo.GetMasterBranchName()) - t.unknown += 1 -} - -func (f *Forge) printRepoToTable(repo *gitpb.Repo, sizes []int, full bool) { - var end string - - // shortened version numbers - var mhort string = repo.GetMasterVersion() - var dhort string = repo.GetDevelVersion() - var uver string = repo.GetUserVersion() - if uver == "uerr" { - // blank these out - uver = "" - } - var lasttag string = repo.GetLastTag() - var thort string = repo.GetTargetVersion() - var chort string = "" // repo.GetCurrentBranchVersion() - var cname string = repo.GetCurrentBranchName() - - var gopath string = repo.GetNamespace() - if gopath == "" { - gopath = repo.GetFullPath() - } - - rtype := f.getRepoType(repo) - - // ctime := repo.Tags.GetAge(mhort) - // age := shell.FormatDuration(time.Since(ctime)) - age := shell.FormatDuration(repo.BranchAge(cname)) - - if f.Config.IsReadOnly(repo.GetGoPath()) { - // end += "(readonly) " - } else { - end += "(rw) " - } - - if repo.IsDirty() { - age = "" - uver = "* " + uver - end += "(dirty) " - } - - var args []string - if full { - args = []string{cname, age, uver, dhort, mhort, chort, lasttag, thort, rtype, gopath} - } else { - args = []string{gopath, cname, age, uver, dhort, mhort, chort, lasttag, thort, rtype} - } - start := cobol.StandardTableSize10(sizes, args) - - if rtype == "protobuf" { - if repo.GoInfo.GoBinary { - end += "(binary) " - } - } - - switch repo.GetState() { - case "PERFECT": - case "unchanged": - case "dirty": - case "unknown branches": - if repo.CurrentTag == nil { - end += "(" + repo.GetState() + ") " - } else { - end += "(unknown branch " + repo.CurrentTag.Refname + ") " - } - // end += "(invalid tag) " - default: - end += "(" + repo.GetState() + ") " - } - - if repo.GetMasterBranchName() != "master" && repo.GetMasterBranchName() != "main" { - end += "(m:" + repo.GetMasterBranchName() + ") " - } - - if repo.GetDevelBranchName() != "devel" { - end += "(d:" + repo.GetDevelBranchName() + ") " - } - - if repo.GetUserBranchName() != f.Config.Username { - end += "(u:" + repo.GetUserBranchName() + ") " - } - - debname := f.Config.DebName(repo.GetNamespace()) - if debname != filepath.Base(gopath) { - end += "(deb:" + debname + ") " - } - - log.Info(cobol.TerminalChomp(start + " " + end)) -} - -func (f *Forge) printForgedToTable(repo *gitpb.Repo, sizes []int) { - var end string - - // shortened version numbers - var mhort string = repo.GetMasterVersion() - var dhort string = repo.GetDevelVersion() - - var lasttag string = repo.GetLastTag() - var cname string = repo.GetCurrentBranchName() - - var ns string = repo.GetNamespace() - - age := shell.FormatDuration(repo.BranchAge(cname)) - - var args []string - args = []string{ns, cname, age, mhort, dhort, lasttag, "", "", "", ""} - start := cobol.StandardTableSize10(sizes, args) - - end += "todo" - - log.Info(cobol.TerminalChomp(start + " " + end)) -} -*/ |
