summaryrefslogtreecommitdiff
path: root/git.go
diff options
context:
space:
mode:
authorJeff Carr <[email protected]>2024-02-22 15:29:22 -0600
committerJeff Carr <[email protected]>2024-02-22 15:29:22 -0600
commitcd5f1d9d0f52196d6ea07684a4307369893911bd (patch)
tree7338ba80799ad96b25eae2fa55bcbca211c48fc7 /git.go
parent5aaf02ee3aeafc17a70ddc32619a17ae19a6f1ed (diff)
add NewestTag() and Tag.Age()
Diffstat (limited to 'git.go')
-rw-r--r--git.go16
1 files changed, 16 insertions, 0 deletions
diff --git a/git.go b/git.go
index 5cfa9eb..c54ab8c 100644
--- a/git.go
+++ b/git.go
@@ -4,6 +4,7 @@ import (
"errors"
"os/user"
"strings"
+ "time"
"unicode/utf8"
"io/ioutil"
@@ -19,6 +20,21 @@ func (rs *RepoStatus) GetCurrentBranchVersion() string {
return rs.currentVersion.String()
}
+func (rs *RepoStatus) Age() time.Duration {
+ var t *Tag
+ t = rs.NewestTag()
+
+ if t != nil {
+ log.Log(REPO, "newest tag:", t.date.String(), t.tag.String(), t.Name())
+ return t.Age()
+ }
+
+ const gitLayout = "Mon Jan 2 15:04:05 2006 -0700"
+ const madeuptime = "Mon Jun 3 15:04:05 2013 -0700"
+ tagTime, _ := time.Parse(gitLayout, madeuptime)
+ return time.Since(tagTime)
+}
+
/*
// this isn't right
func (rs *RepoStatus) LastTagAge() (time.Time, string) {