diff options
| author | Jeff Carr <[email protected]> | 2024-02-22 15:29:22 -0600 |
|---|---|---|
| committer | Jeff Carr <[email protected]> | 2024-02-22 15:29:22 -0600 |
| commit | cd5f1d9d0f52196d6ea07684a4307369893911bd (patch) | |
| tree | 7338ba80799ad96b25eae2fa55bcbca211c48fc7 /git.go | |
| parent | 5aaf02ee3aeafc17a70ddc32619a17ae19a6f1ed (diff) | |
add NewestTag() and Tag.Age()
Diffstat (limited to 'git.go')
| -rw-r--r-- | git.go | 16 |
1 files changed, 16 insertions, 0 deletions
@@ -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) { |
