diff options
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 +} |
