We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
I think I have found a bug in the constraint check for .0 patch prereleases.
.0
An example for this can be found in the Go Playground https://go.dev/play/p/LShjC5F37TT or in the main.go:
package main import ( "fmt" "github.com/blang/semver/v4" ) func main() { constraint := "0.49.x" versionConstraint, err := semver.ParseRange(constraint) if err != nil { return } versions := []string{ "0.49.0-alpha", "0.49.1-alpha", "0.49.0", "0.49.1", } for _, ver := range versions { parsedVersion, err := semver.Parse(ver) if err != nil { return } fmt.Printf("%v becomes:\n %#v \n", ver, parsedVersion) fmt.Printf(" Major: %d\n", parsedVersion.Major) fmt.Printf(" Minor: %d\n", parsedVersion.Minor) fmt.Printf(" Patch: %d\n", parsedVersion.Patch) fmt.Printf(" Pre: %s\n", parsedVersion.Pre) fmt.Printf(" Build: %s\n", parsedVersion.Build) didMatch := "false" if versionConstraint(parsedVersion) { didMatch = "true" } fmt.Printf(" => constraint %v matched for %v: %v \n\n", constraint, ver, didMatch) } }
The output of this is:
0.49.0-alpha becomes: semver.Version{Major:0x0, Minor:0x31, Patch:0x0, Pre:[]semver.PRVersion{semver.PRVersion{VersionStr:"alpha", VersionNum:0x0, IsNum:false}}, Build:[]string(nil)} Major: 0 Minor: 49 Patch: 0 Pre: [alpha] Build: [] => constraint 0.49.x matched for 0.49.0-alpha: false // ❌ this seems to be a bug 0.49.1-alpha becomes: semver.Version{Major:0x0, Minor:0x31, Patch:0x1, Pre:[]semver.PRVersion{semver.PRVersion{VersionStr:"alpha", VersionNum:0x0, IsNum:false}}, Build:[]string(nil)} Major: 0 Minor: 49 Patch: 1 Pre: [alpha] Build: [] => constraint 0.49.x matched for 0.49.1-alpha: true // ✅ as expected 0.49.0 becomes: semver.Version{Major:0x0, Minor:0x31, Patch:0x0, Pre:[]semver.PRVersion(nil), Build:[]string(nil)} Major: 0 Minor: 49 Patch: 0 Pre: [] Build: [] => constraint 0.49.x matched for 0.49.0: true // ✅ as expected 0.49.1 becomes: semver.Version{Major:0x0, Minor:0x31, Patch:0x1, Pre:[]semver.PRVersion(nil), Build:[]string(nil)} Major: 0 Minor: 49 Patch: 1 Pre: [] Build: [] => constraint 0.49.x matched for 0.49.1: true // ✅ as expected
According to this SemVer check, that's incorrect: https://jubianchi.github.io/semver-check/#/0.49.x/0.49.0-alpha.
The text was updated successfully, but these errors were encountered:
No branches or pull requests
I think I have found a bug in the constraint check for
.0
patch prereleases.An example for this can be found in the Go Playground https://go.dev/play/p/LShjC5F37TT or in the main.go:
main.go (expand)
The output of this is:
According to this SemVer check, that's incorrect: https://jubianchi.github.io/semver-check/#/0.49.x/0.49.0-alpha.
The text was updated successfully, but these errors were encountered: