Skip to content

Commit 25424d4

Browse files
committed
Strip v prefix when looking for match
Signed-off-by: Kimmo Lehto <[email protected]>
1 parent 8af6745 commit 25424d4

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

release.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ func LatestReleaseByPrerelease(allowpre bool) (Release, error) {
7272
latest := c[len(c)-1].String()
7373

7474
for _, v := range releases {
75-
if v.TagName == latest {
75+
if strings.TrimPrefix(v.TagName, "v") == latest {
7676
return v, nil
7777
}
7878
}

release_test.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
package version
2+
3+
import (
4+
"regexp"
5+
"testing"
6+
7+
"github.com/stretchr/testify/assert"
8+
)
9+
10+
func TestLatestReleaseByPrerelease(t *testing.T) {
11+
r, err := LatestReleaseByPrerelease(false)
12+
assert.NoError(t, err)
13+
assert.Regexp(t, regexp.MustCompile(`\d+\.\d+\.\d+\+k0s\.\d+`), r)
14+
}

0 commit comments

Comments
 (0)