diff options
| author | Jeff Carr <[email protected]> | 2024-03-02 17:52:45 -0600 |
|---|---|---|
| committer | Jeff Carr <[email protected]> | 2024-03-02 17:52:45 -0600 |
| commit | 412c84fcd9f40350eeec767b7367d6d1fed0fabb (patch) | |
| tree | c698fa27508b1bcca498e75330f503eec50b0bc3 /common.go | |
| parent | b2d3d13ed9992aab812184009303e1a1be305194 (diff) | |
generate valid DebianVersions()v0.21.4
Diffstat (limited to 'common.go')
| -rw-r--r-- | common.go | 37 |
1 files changed, 37 insertions, 0 deletions
@@ -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 +} |
