might show branch age?

This commit is contained in:
Jeff Carr 2025-01-19 10:49:08 -06:00
parent 966e3d7858
commit 53acead41e
1 changed files with 31 additions and 0 deletions

View File

@ -104,3 +104,34 @@ func (repo *Repo) NewestAgeVerbose() time.Duration {
return time.Since(newest)
}
// not really accurate. temprorary until git Config() parsing is better
func (repo *Repo) BranchAge(branch string) time.Duration {
alltags := repo.Tags.selectAllGitTags()
var newest time.Time
var cur time.Time
var auth time.Time
for _, tag := range alltags {
cur = tag.Creatordate.AsTime()
auth = tag.Authordate.AsTime()
if branch == filepath.Base(tag.Refname) {
// log.Info("\t\tfound tag", i, branch, tag.Authordate.AsTime(), tag.Creatordate.AsTime())
if cur.Before(auth) {
return time.Since(auth)
}
return time.Since(cur)
}
// check both dates I guess
if newest.Before(auth) {
newest = auth
}
if newest.Before(cur) {
newest = cur
}
}
return time.Since(newest)
}