summaryrefslogtreecommitdiff
path: root/common.go
diff options
context:
space:
mode:
Diffstat (limited to 'common.go')
-rw-r--r--common.go37
1 files changed, 37 insertions, 0 deletions
diff --git a/common.go b/common.go
index 7daa87a..eab7925 100644
--- a/common.go
+++ b/common.go
@@ -2,6 +2,7 @@ package repostatus
import (
"strings"
+ "unicode"
"go.wit.com/log"
// "go.wit.com/gui/gui"
@@ -206,3 +207,39 @@ func (rs *RepoStatus) Name() string {
}
return rs.Path()
}
+
+func trimNonNumericFromStart(s string) string {
+ for i, r := range s {
+ if unicode.IsDigit(r) {
+ return s[i:]
+ }
+ }
+ return ""
+}
+
+func (rs *RepoStatus) DebianReleaseVersion() string {
+ lasttag := rs.GetLastTagVersion()
+ newv := trimNonNumericFromStart(lasttag)
+ if newv == "" {
+ newv = "0.0"
+ if lasttag != "" {
+ newv += "-" + lasttag
+ }
+ }
+ log.Info("ValidDebianPackageVersion:", newv)
+ return newv
+}
+
+func (rs *RepoStatus) DebianCurrentVersion() string {
+ cbversion := rs.GetCurrentBranchVersion()
+
+ newv := trimNonNumericFromStart(cbversion)
+ if newv == "" {
+ newv = "0.0"
+ }
+ if rs.CheckDirty() {
+ newv += "-dirty"
+ }
+ log.Info("ValidDebianPackageVersion:", newv)
+ return newv
+}