summaryrefslogtreecommitdiff
path: root/common.go
diff options
context:
space:
mode:
authorJeff Carr <[email protected]>2024-03-02 17:52:45 -0600
committerJeff Carr <[email protected]>2024-03-02 17:52:45 -0600
commit412c84fcd9f40350eeec767b7367d6d1fed0fabb (patch)
treec698fa27508b1bcca498e75330f503eec50b0bc3 /common.go
parentb2d3d13ed9992aab812184009303e1a1be305194 (diff)
generate valid DebianVersions()v0.21.4
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
+}