summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gitTag.byAge.go31
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)
+}