summaryrefslogtreecommitdiff
path: root/currentVersions.go
diff options
context:
space:
mode:
authorJeff Carr <[email protected]>2025-10-15 07:36:40 -0500
committerJeff Carr <[email protected]>2025-10-15 07:36:40 -0500
commit2d16120dc2d924fe6214388f3fc8852b6f99e64c (patch)
tree00ed21277d854c89ede8e3bcc6782ccd1e2b6383 /currentVersions.go
parenta646579861447030b1fb5831f05fef2eacbd6c12 (diff)
fix to debian standards
Diffstat (limited to 'currentVersions.go')
-rw-r--r--currentVersions.go32
1 files changed, 23 insertions, 9 deletions
diff --git a/currentVersions.go b/currentVersions.go
index 40ae14d..8675e82 100644
--- a/currentVersions.go
+++ b/currentVersions.go
@@ -5,6 +5,7 @@ package gitpb
import (
"errors"
+ "fmt"
"path/filepath"
"regexp"
"strconv"
@@ -116,17 +117,30 @@ func (repo *Repo) DebianReleaseVersion() string {
return newv
}
-func (repo *Repo) DebianCurrentVersion() string {
- cbversion := repo.GetCurrentBranchVersion()
+func (repo *Repo) DebianCurrentVersion(buildnum int) string {
+ curver := repo.GetCurrentBranchVersion()
- newv := trimNonNumericFromStart(cbversion)
- if newv == "" {
- newv = "0.0"
+ // takes off the GO 'v'
+ curver = trimNonNumericFromStart(curver)
+ if curver == "" {
+ // need something for debian or it won't accept it
+ curver = "0.0"
}
- //if repo.CheckDirty() {
- // newv += "-dirty"
- //}
- return newv
+
+ // .deb files don't like "v0.0.90-1-g778234j"
+ // so remove the end so it's "0.0.90-1"
+ parts := strings.Split(curver, "-")
+ if len(parts) > 0 {
+ curver = strings.Join(parts[0:2], "-")
+ }
+
+ // optionally debian supports build numbers
+ if buildnum != 0 {
+ // this would be the 3rd build: "0.0.90-1+b3"
+ curver += fmt.Sprintf("+b%d", buildnum)
+ }
+
+ return curver
}
func (repo *Repo) gitVersionByName(name string) (string, error) {