Skip to content

Support for version constraint wildcards - #3

Open
beornf wants to merge 1 commit into
aquasecurity:mainfrom
beornf:version-wildcard
Open

Support for version constraint wildcards#3
beornf wants to merge 1 commit into
aquasecurity:mainfrom
beornf:version-wildcard

Conversation

@beornf

@beornf beornf commented Feb 12, 2023

Copy link
Copy Markdown

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

CLAassistant commented Feb 12, 2023

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@beornf

beornf commented Oct 22, 2024

Copy link
Copy Markdown
Author

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.

@knqyf263 knqyf263 left a comment

Copy link
Copy Markdown
Collaborator

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 thread pkg/version/constraint.go
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
Copy Markdown
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
Copy Markdown
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