more accurate repo Age()

This commit is contained in:
Jeff Carr 2025-01-17 04:47:47 -06:00
parent 9e81be86da
commit 0f232fe342
2 changed files with 29 additions and 2 deletions

View File

@ -22,6 +22,7 @@ goimports:
clean:
rm -f *.pb.go
-rm -f go.*
go-mod-clean --purge
forgeConfig.pb.go: forgeConfig.proto
autogenpb --proto forgeConfig.proto

View File

@ -41,7 +41,31 @@ func (f *Forge) PrintHumanTable(allr *gitpb.Repos) {
all := allr.SortByFullPath()
for all.Scan() {
repo := all.Next()
f.sendRepoToTable(repo)
f.printRepoToTable(repo)
count += 1
}
log.Info("Total git repositories:", count)
}
// also shows which files are dirty
func (f *Forge) PrintHumanTableDirty(allr *gitpb.Repos) {
log.DaemonMode(true)
var count int
// 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 := allr.SortByFullPath()
for all.Scan() {
repo := all.Next()
f.printRepoToTable(repo)
if len(repo.DirtyList) != 0 {
for _, line := range repo.DirtyList {
log.Info("\t", line)
}
}
var mver string = repo.GetMasterVersion()
repo.Tags.GetAge(mver)
count += 1
}
log.Info("Total git repositories:", count)
@ -133,7 +157,7 @@ func standardTable8(arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9 string)
return fmt.Sprintf(s, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9)
}
func (f *Forge) sendRepoToTable(repo *gitpb.Repo) {
func (f *Forge) printRepoToTable(repo *gitpb.Repo) {
var end string
if repo.IsDirty() {
end += "(dirty) "
@ -148,6 +172,8 @@ func (f *Forge) sendRepoToTable(repo *gitpb.Repo) {
var gopath string = repo.GetGoPath()
var rtype string = repo.GetRepoType()
// ctime := repo.Tags.GetAge(mhort)
// age := shell.FormatDuration(time.Since(ctime))
age := shell.FormatDuration(repo.NewestAge())
start := standardTable8(gopath, cname, age, thort, mhort, dhort, uhort, chort, rtype)