Skip to content

Commit 581a5e8

Browse files
committed
Add support for upstream tag that is not <version> or v<version>
e.g. github.com/lxc/lxd with tag lxd-4.8 Fixes Debian#139
1 parent adbf657 commit 581a5e8

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

make.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ type upstream struct {
107107
tarPath string // path to the downloaded or generated orig tarball tempfile
108108
compression string // compression method, either "gz" or "xz"
109109
version string // Debian package upstream version number, e.g. 0.0~git20180204.1d24609
110+
tag string // Latest upstream tag, if any
110111
commitIsh string // commit-ish corresponding to upstream version to be packaged
111112
remote string // git remote, set to short hostname if upstream git history is included
112113
firstMain string // import path of the first main package within repo, if any
@@ -144,16 +145,16 @@ func (u *upstream) tarballFromHoster() error {
144145

145146
switch repoU.Host {
146147
case "github.com":
147-
tarURL = fmt.Sprintf("%s/archive/v%s.tar.%s",
148-
repo, u.version, u.compression)
148+
tarURL = fmt.Sprintf("%s/archive/%s.tar.%s",
149+
repo, u.tag, u.compression)
149150
case "gitlab.com":
150151
parts := strings.Split(repoU.Path, "/")
151152
if len(parts) < 3 {
152153
return fmt.Errorf("Incomplete repo URL: %s", u.rr.Repo)
153154
}
154155
project := parts[2]
155-
tarURL = fmt.Sprintf("%s/-/archive/v%[3]s/%[2]s-%s.tar.%s",
156-
repo, project, u.version, u.compression)
156+
tarURL = fmt.Sprintf("%s/-/archive/%s/%s-%s.tar.%s",
157+
repo, u.tag, project, u.tag, u.compression)
157158
default:
158159
return fmt.Errorf("Unsupported hoster")
159160
}

version.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import (
99
"strconv"
1010
"strings"
1111
"time"
12+
"unicode"
1213
)
1314

1415
var (
@@ -37,6 +38,7 @@ func pkgVersionFromGit(gitdir string, u *upstream, forcePrerelease bool) (string
3738
if out, err := cmd.Output(); err == nil {
3839
latestTag = strings.TrimSpace(string(out))
3940
u.hasRelease = true
41+
u.tag = latestTag
4042
log.Printf("Found latest tag %q", latestTag)
4143

4244
if !semverRegexp.MatchString(latestTag) {
@@ -64,7 +66,9 @@ func pkgVersionFromGit(gitdir string, u *upstream, forcePrerelease bool) (string
6466
}
6567

6668
u.commitIsh = latestTag
67-
u.version = strings.TrimPrefix(latestTag, "v")
69+
u.version = strings.TrimLeftFunc(latestTag, func(r rune) bool {
70+
return !unicode.IsNumber(r)
71+
})
6872

6973
if forcePrerelease {
7074
log.Printf("INFO: Force packaging master (prerelease) as requested by user")

0 commit comments

Comments
 (0)