Skip to content

Commit

Permalink
Strip v prefix when looking for match
Browse files Browse the repository at this point in the history
Signed-off-by: Kimmo Lehto <[email protected]>
  • Loading branch information
kke committed Feb 8, 2022
1 parent 8af6745 commit 25424d4
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
2 changes: 1 addition & 1 deletion release.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ func LatestReleaseByPrerelease(allowpre bool) (Release, error) {
latest := c[len(c)-1].String()

for _, v := range releases {
if v.TagName == latest {
if strings.TrimPrefix(v.TagName, "v") == latest {
return v, nil
}
}
Expand Down
14 changes: 14 additions & 0 deletions release_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package version

import (
"regexp"
"testing"

"github.com/stretchr/testify/assert"
)

func TestLatestReleaseByPrerelease(t *testing.T) {
r, err := LatestReleaseByPrerelease(false)
assert.NoError(t, err)
assert.Regexp(t, regexp.MustCompile(`\d+\.\d+\.\d+\+k0s\.\d+`), r)
}

0 comments on commit 25424d4

Please sign in to comment.