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

Support wildcards in versions #27

Merged
merged 6 commits into from
Jan 30, 2017

Conversation

alexandernst
Copy link
Contributor

This implements #24

The code will expand wildcards inside versions following these rules:

* when dealing with patch wildcards:
>= 1.2.x    will become    >= 1.2.0
<= 1.2.x    will become    <  1.3.0
>  1.2.x    will become    >= 1.3.0
<  1.2.x    will become    <  1.2.0
!= 1.2.x    will become    <  1.2.0 >= 1.3.0
* when dealing with minor wildcards:
>= 1.x      will become    >= 1.0.0
<= 1.x      will become    <  2.0.0
>  1.x      will become    >= 2.0.0
<  1.0      will become    <  1.0.0
!= 1.x      will become    <  1.0.0 >= 2.0.0
* when dealing with wildcards without version operator:
1.2.x       will become    >= 1.2.0 < 1.3.0
1.x         will become    >= 1.0.0 < 2.0.0

@blang
Copy link
Owner

blang commented Jan 24, 2017

Thank you very much, looks good at the first impression, please give me some time to review this, since i'm quite busy in the next couple of days

@alexandernst
Copy link
Contributor Author

Take your time @blang ;)
The same as with the other PR, if you feel that something is missing or you need me to do something extra, ask and I'll do it.

@alexandernst
Copy link
Contributor Author

@blang Any news on this? :)

Copy link
Owner

@blang blang left a comment

Choose a reason for hiding this comment

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

I finally found some time to look into it, here are a couple of points that caught my attention:

  • There are no end2end tests (TestParseRange)
  • No full test coverage
  • use constants and iota for constants:
type wildcardType int

const (
	noneWildcard wildcardType = iota
	majorWildcard
	minorWildcard
	patchWildcard
)

// getWildcardType will return the type of wildcard that the
// passed version contains
func getWildcardType(vStr string) wildcardType {
parts := strings.Split(vStr, ".")
Copy link
Owner

Choose a reason for hiding this comment

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

Might not work for prerelease and build metadata version information since it may contain dots like '1.0.0-1.x.x' which is a valid version:
http://semver.org/#spec-item-9

Copy link
Owner

Choose a reason for hiding this comment

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

That's only an issue if pr and build metadata versions are allowed as ranges, sadly i haven't written tests for that case in the first place, therefor that's open for discussion

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That can't happen as getWildcardType is executed on each splitted version, meaning that, with your example, getWildcardType will be called with 1.0.0 and 1.x.x.

@alexandernst
Copy link
Contributor Author

@blang I wrote more tests to push the code coverage to 100% and I wrote end2end tests for the ParseRange function. I also replied to the concern you have about the getWildcardType function misbehaving with wrong parameters. Can you check the new commits, please?

@blang
Copy link
Owner

blang commented Jan 30, 2017

LGTM, thanks, good work

@blang blang merged commit b38d23b into blang:master Jan 30, 2017
alexandernst added a commit to vmware-archive/semver that referenced this pull request Feb 2, 2017
... covering changes in blang#26 and blang#27
@alexandernst alexandernst mentioned this pull request Feb 2, 2017
blang pushed a commit that referenced this pull request Feb 2, 2017
... covering changes in #26 and #27
Fixes #28
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.

None yet

2 participants