2024-11-04 06:15:45 -06:00
|
|
|
package repolist
|
|
|
|
|
|
|
|
// make human readable output
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"time"
|
|
|
|
|
|
|
|
"go.wit.com/lib/gui/shell"
|
2024-11-04 08:13:37 -06:00
|
|
|
"go.wit.com/log"
|
2024-11-04 06:15:45 -06:00
|
|
|
)
|
|
|
|
|
|
|
|
// makes a human readable thing for standard out.
|
2024-11-13 17:05:07 -06:00
|
|
|
// https://pkg.go.dev/fmt has good references for Sprintf
|
2024-11-04 06:15:45 -06:00
|
|
|
func (r *RepoRow) StandardHeader() string {
|
|
|
|
lastTag := r.LastTag()
|
|
|
|
tag := r.Status.NewestTag()
|
|
|
|
gitAge, _ := tag.GetDate()
|
|
|
|
dur := time.Since(gitAge)
|
|
|
|
|
2024-11-05 03:14:27 -06:00
|
|
|
target := r.Status.GetTargetVersion()
|
2024-11-04 06:15:45 -06:00
|
|
|
master := r.Status.GetMasterVersion()
|
|
|
|
devel := r.Status.GetDevelVersion()
|
|
|
|
user := r.Status.GetUserVersion()
|
|
|
|
|
2024-11-05 05:58:33 -06:00
|
|
|
header := fmt.Sprintf("%-35s %5s %-10s %-10s %-20s %-20s %-20s %-15s",
|
2024-11-08 06:43:45 -06:00
|
|
|
r.Name(), shell.FormatDuration(dur),
|
2024-11-05 03:14:27 -06:00
|
|
|
lastTag, target,
|
2024-11-08 06:43:45 -06:00
|
|
|
master, devel, user,
|
2024-11-05 03:14:27 -06:00
|
|
|
r.State())
|
2024-11-04 08:13:37 -06:00
|
|
|
return header
|
|
|
|
}
|
|
|
|
|
2024-11-05 05:58:33 -06:00
|
|
|
func ReportHeader() string {
|
|
|
|
return fmt.Sprintf("%-35s %5s %-10s %-10s %-20s %-20s %-20s %-15s",
|
2024-11-04 17:13:48 -06:00
|
|
|
"REPO", "AGE",
|
2024-11-05 03:14:27 -06:00
|
|
|
"LAST", "TARGET",
|
|
|
|
"MASTER", "DEVEL", "USER",
|
2024-11-04 17:13:48 -06:00
|
|
|
"STATE")
|
2024-11-05 05:58:33 -06:00
|
|
|
}
|
|
|
|
|
2024-11-07 05:07:36 -06:00
|
|
|
func (v *RepoList) PrintReport(readonly string, onlydirty string, perfect string) {
|
2024-11-05 05:58:33 -06:00
|
|
|
var count int
|
|
|
|
|
2024-11-07 03:41:26 -06:00
|
|
|
log.Info(ReportHeader())
|
2024-11-04 17:13:48 -06:00
|
|
|
|
2024-11-04 08:13:37 -06:00
|
|
|
loop := v.ReposSortByName()
|
|
|
|
for loop.Scan() {
|
|
|
|
repo := loop.Repo()
|
|
|
|
|
|
|
|
count += 1
|
|
|
|
header := repo.StandardHeader()
|
|
|
|
if onlydirty == "true" {
|
|
|
|
if repo.CheckDirty() {
|
2024-11-08 06:43:45 -06:00
|
|
|
log.Info(header + "")
|
2024-11-04 08:13:37 -06:00
|
|
|
}
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
|
|
|
|
if repo.ReadOnly() {
|
|
|
|
if readonly == "true" {
|
2024-11-08 06:43:45 -06:00
|
|
|
log.Info(header + "readonly")
|
2024-11-04 08:13:37 -06:00
|
|
|
}
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
if repo.State() == "PERFECT" {
|
|
|
|
if perfect == "false" {
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if repo.State() != "merge to main" {
|
2024-11-08 06:43:45 -06:00
|
|
|
log.Info(header + "")
|
2024-11-04 08:13:37 -06:00
|
|
|
continue
|
|
|
|
}
|
|
|
|
if repo.CheckDirty() {
|
2024-11-08 06:43:45 -06:00
|
|
|
log.Info(header + "")
|
2024-11-04 08:13:37 -06:00
|
|
|
continue
|
|
|
|
}
|
2024-11-08 06:43:45 -06:00
|
|
|
log.Info(header + "")
|
2024-11-04 08:13:37 -06:00
|
|
|
}
|
2024-11-07 03:41:26 -06:00
|
|
|
log.Info(fmt.Sprintf("EVERYTHING WORKED repo count = %d", count))
|
2024-11-04 08:13:37 -06:00
|
|
|
}
|
|
|
|
|
2024-11-04 17:13:48 -06:00
|
|
|
// makes a human readable thing for standard out.
|
|
|
|
func (r *RepoRow) StandardReleaseHeader() string {
|
|
|
|
lastTag := r.LastTag()
|
|
|
|
tag := r.Status.NewestTag()
|
|
|
|
gitAge, _ := tag.GetDate()
|
|
|
|
dur := time.Since(gitAge)
|
|
|
|
|
|
|
|
curname := r.Status.GetCurrentBranchName()
|
|
|
|
master := r.Status.GetMasterVersion()
|
2024-11-05 01:02:00 -06:00
|
|
|
user := r.Status.GetUserVersion()
|
2024-11-04 17:13:48 -06:00
|
|
|
target := r.Status.GetTargetVersion()
|
|
|
|
|
2024-11-05 05:58:33 -06:00
|
|
|
header := fmt.Sprintf("%-35s %5s %-10s %-10s %-10s %-20s %-20s %-15s",
|
|
|
|
r.Name(), shell.FormatDuration(dur), curname,
|
|
|
|
lastTag, target,
|
|
|
|
master, user,
|
2024-11-04 17:13:48 -06:00
|
|
|
r.State())
|
|
|
|
return header
|
|
|
|
}
|
|
|
|
|
2024-11-05 05:58:33 -06:00
|
|
|
func ReleaseReportHeader() string {
|
|
|
|
return fmt.Sprintf("%-35s %5s %-10s %-10s %-10s %-20s %-20s %-15s",
|
|
|
|
"REPO", "AGE", "CUR BR",
|
|
|
|
"LAST", "TARGET",
|
|
|
|
"MASTER", "USER",
|
|
|
|
"STATE")
|
|
|
|
}
|
|
|
|
|
2024-11-07 05:07:36 -06:00
|
|
|
func (v *RepoList) PrintReleaseReport(readonly string, perfect string) {
|
2024-11-04 08:13:37 -06:00
|
|
|
var count int
|
|
|
|
|
2024-11-07 03:41:26 -06:00
|
|
|
log.Info(ReleaseReportHeader())
|
2024-11-04 17:13:48 -06:00
|
|
|
|
2024-11-04 08:13:37 -06:00
|
|
|
loop := v.ReposSortByName()
|
|
|
|
for loop.Scan() {
|
|
|
|
repo := loop.Repo()
|
|
|
|
|
|
|
|
if repo.ReadOnly() && (readonly == "true") {
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
if (repo.State() == "PERFECT") && (perfect == "true") {
|
|
|
|
continue
|
|
|
|
}
|
2024-11-04 17:13:48 -06:00
|
|
|
if repo.Status.IsReleased() {
|
|
|
|
continue
|
|
|
|
}
|
2024-11-04 08:13:37 -06:00
|
|
|
count += 1
|
|
|
|
header := repo.StandardReleaseHeader()
|
2024-11-07 03:41:26 -06:00
|
|
|
log.Info(header)
|
2024-11-04 08:13:37 -06:00
|
|
|
}
|
2024-11-07 03:41:26 -06:00
|
|
|
log.Info(fmt.Sprintf("total repo count = %d", count))
|
2024-11-04 08:13:37 -06:00
|
|
|
}
|