Repository navigation
add Core func - #85
Conversation
|
Perhaps we could call this function |
radeksimko
left a comment
There was a problem hiding this comment.
LGTM, I suppose this doesn't need too wide attention/approval given that the change is additive and shouldn't break existing usage, but it would be useful to have an additional 👍🏻 from TF core.
alisdair
left a comment
There was a problem hiding this comment.
This makes sense to me, and I think we'd probably use it to address hashicorp/terraform#28148 while still preserving the existing behaviour of ignoring prerelease versions when evaluating version constraint inequalities.
Adds a Core function to Version, which returns a new Version created from only the MAJOR.MINOR.PATCH segments of the original version, without prerelease or metadata strings. Consumers of go-version often want to treat prereleases of versions as equal to non-prerelease versions, e.g. 0.15.0-dev as equal to 0.15.0. The present functionality is intended as an easy way to opt in to this behaviour.
|
The semver spec actually calls this core in the grammar (https://semver.org/#backusnaur-form-grammar-for-valid-semver-versions), so I've renamed it. Would appreciate a go-ahead from both of you on this. |
Adds a Core function to Version, which returns a new Version created from only the MAJOR.MINOR.PATCH segments of the original version, without prerelease or metadata strings.
Consumers of go-version often want to treat prereleases of versions as equal to non-prerelease versions, e.g. 0.15.0-dev as equal to 0.15.0. The present functionality is intended as an easy way to opt in to this behaviour.
Example in a library used by the Terraform Language Server:
https://github.com/hashicorp/terraform-schema/blob/8c206fbd85ae346716b4efbd776c8b8097fc5b42/schema/core_schema.go#L47-L52