Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(version): Versions should support int64 integers #35

Closed
wants to merge 2 commits into from

Conversation

kmala
Copy link

@kmala kmala commented Dec 5, 2016

fixes #34

Copy link
Member

@mattfarina mattfarina left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Take a look at parseConstraint. I think this is where the constraint failure is happening.

If you won't have time to run with this let me know and I'm happy to help finish this off.

@@ -32,6 +32,7 @@ func TestNewVersion(t *testing.T) {
{"v1.2.3-rc1-with-hypen", false},
{"1.2.3.4", true},
{"v1.2.3.4", true},
{"20161202202307-sha.e8fc5e5", false},
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The test you're using isn't really semver. What about using the example v2.3.5-20161202202307-sha.e8fc5e5 from the ticket?

On the tip of master the test for v2.3.5-20161202202307-sha.e8fc5e5 passes for this test. There should be a constraints test for this which fails for this PR.

It's the constraint handling rather than the version handling that's failing for this case.

@@ -59,14 +59,14 @@ func NewVersion(v string) (*Version, error) {
}

var temp int64
temp, err := strconv.ParseInt(m[1], 10, 32)
temp, err := strconv.ParseInt(m[1], 10, 64)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm ok with the change to 64 even though it's not impacting.

@mattfarina mattfarina mentioned this pull request Dec 6, 2016
@kmala
Copy link
Author

kmala commented Dec 6, 2016

Yes...when i call NewConstraint(">=v2.3.5-20161202202307-sha.e8fc5e5") , it is calling parseConstraint(">= v2.3.5") and parseConstraint("<= 20161202202307-sha.e8fc5e5") which then calls NewVersion() (https://github.com/Masterminds/semver/blob/master/constraints.go#L185) which is where it is failing with error Error parsing version segment: strconv.ParseInt: parsing "20161202202307": value out of range

@sdboyer
Copy link
Member

sdboyer commented Dec 6, 2016

Interesting...that's a bug in the parser then; it's treating that first dash as a range operator between two separate versions, rather than conjoining the two parts of the string.

@mattfarina
Copy link
Member

mattfarina commented Dec 7, 2016

I believe the underlying issue is here.

`\s*(%s)\s*-\s*(%s)\s*`,

Should be

`\s*(%s)\s+-\s+(%s)\s*`,

There should be one or more spaces. This is a typo. The intent was the required space in the hyphen range syntax.

@kmala
Copy link
Author

kmala commented Dec 7, 2016

@mattfarina i made the change for the regex.Also i kept the change for the int64 which i can remove if you want.

@mattfarina
Copy link
Member

As an alternative I wrote #36. This solves the same #34 issue.

@mattfarina
Copy link
Member

I just merged #36 which fixes #34. So, closing this one.

@mattfarina mattfarina closed this Dec 13, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

constraint Parser Error
3 participants