summaryrefslogtreecommitdiff
path: root/gitTag.common.go
diff options
context:
space:
mode:
Diffstat (limited to 'gitTag.common.go')
-rw-r--r--gitTag.common.go28
1 files changed, 28 insertions, 0 deletions
diff --git a/gitTag.common.go b/gitTag.common.go
index d349dea..43c0dbc 100644
--- a/gitTag.common.go
+++ b/gitTag.common.go
@@ -102,3 +102,31 @@ func (repo *Repo) IsLocalBranch(findname string) bool {
log.Log(INFO, "did not find tag:", findname, "in", repo.GetGoPath())
return false
}
+
+// finds the newest tag. used for deciding if master needs to be published
+func (repo *Repo) FindLastTag() string {
+ var newest *GitTag
+ all := repo.Tags.All()
+ for all.Scan() {
+ tag := all.Next()
+ if !strings.HasPrefix(tag.GetRefname(), "refs/tags/") {
+ continue
+ }
+ if newest == nil {
+ newest = tag
+ continue
+ }
+ cur := newest.Creatordate.AsTime()
+ if cur.Before(tag.Creatordate.AsTime()) {
+ newest = tag
+ }
+ // newtag := strings.TrimPrefix(tag.GetRefname(), "refs/tags/")
+ // log.Info("repo tag", tag.GetHash(), tag.Creatordate.AsTime(), tag.GetRefname(), newtag)
+ }
+ if newest == nil {
+ return ""
+ }
+ // log.Info("repo newest tag", newest.GetHash(), newest.Creatordate.AsTime(), newest.GetRefname())
+ newtag := strings.TrimPrefix(newest.GetRefname(), "refs/tags/")
+ return newtag
+}