diff options
Diffstat (limited to 'currentVersions.go')
| -rw-r--r-- | currentVersions.go | 32 |
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) { |
