Skip to content

Commit

Permalink
fix: Ignoring major version that looks like a date
Browse files Browse the repository at this point in the history
Signed-off-by: Vincent Boutour <bob@vibioh.fr>
  • Loading branch information
ViBiOh committed Sep 7, 2021
1 parent 71b40e7 commit 89b4673
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
4 changes: 4 additions & 0 deletions pkg/semver/semver.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,10 @@ func Parse(version string) (Version, error) {
}
var err error

if len(matches[1]) >= 8 {
return NoneVersion, fmt.Errorf("major version looks like a date: %s", version)
}

semver.major, err = strconv.ParseUint(matches[1], 10, 64)
if err != nil {
return NoneVersion, fmt.Errorf("version major is not numeric")
Expand Down
8 changes: 8 additions & 0 deletions pkg/semver/semver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,14 @@ func TestParse(t *testing.T) {
Version{"v1.2.3-abcdef123456", 1, 2, 3, 0},
nil,
},
{
"fucking date",
args{
version: "v20160726",
},
Version{},
errors.New("major version looks like a date"),
},
}

for _, tc := range cases {
Expand Down

0 comments on commit 89b4673

Please sign in to comment.