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 for version constraint wildcards #3

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

beornf
Copy link

@beornf beornf commented Feb 12, 2023

I discovered you started a library after commenting on my PR at hashicorp/go-version#49. I've written this PR which adds support for version wildcards and passes all https://github.com/Masterminds/semver test cases.

This also addresses a few issues:

  • Repeated calls to Constraints Check will mutate the object in PessimisticBump, TildeBump and CaretBump
  • Adding a prerelease check for all constraint functions
  • Empty string is treated the same as wildcards

@CLAassistant
Copy link

CLAassistant commented Feb 12, 2023

CLA assistant check
All committers have signed the CLA.

@beornf
Copy link
Author

beornf commented Oct 22, 2024

I have reworked this PR so there are no breaking changes to existing test cases. I have also added support for range constraints for example, 1 - 2.

Copy link
Collaborator

@knqyf263 knqyf263 left a comment

Choose a reason for hiding this comment

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

We're sorry to miss this PR.

Comment on lines +133 to +141
var segments []part.Part
for _, str := range strings.Split(m[3], ".") {
segments = append(segments, part.NewPart(str))
}

v := Version{
segments: segments,
preRelease: part.NewParts(m[6]),
original: c,
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm curious why Parse doesn't fit here.

Copy link
Author

Choose a reason for hiding this comment

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

If we use Parse from version.go here that means a valid version would be 1.2.x. So instead it's necessary to parse the segments here to create a valid "constraint" version.

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.

3 participants