diff options
| author | Jeff Carr <[email protected]> | 2025-01-19 10:49:08 -0600 |
|---|---|---|
| committer | Jeff Carr <[email protected]> | 2025-01-19 10:49:08 -0600 |
| commit | 53acead41ec431b69c524d363e0514c9f347430e (patch) | |
| tree | 602e05da8322e9c6a956159988215feecf5b4779 | |
| parent | 966e3d785898a0ba17e87b7045e36b811519e212 (diff) | |
might show branch age?v0.0.62
| -rw-r--r-- | gitTag.byAge.go | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/gitTag.byAge.go b/gitTag.byAge.go index 0033c45..f5e3188 100644 --- a/gitTag.byAge.go +++ b/gitTag.byAge.go @@ -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) +} |
