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

strict version check constraint bug (or expected?) #242

Open
Diliz opened this issue Jun 13, 2024 · 0 comments
Open

strict version check constraint bug (or expected?) #242

Diliz opened this issue Jun 13, 2024 · 0 comments

Comments

@Diliz
Copy link

Diliz commented Jun 13, 2024

Hello!

I actually saw that the version constraint sometimes does not work as expected, as you can see here: https://go.dev/play/p/u1nq3v1-SiS

I got the following versions:

"1.0.0",
"1.0.0-beta.2"
"1.0.0-beta.1"
"1.0.0-alpha.2"
"1.0.0-alpha.1"
"1.0.0+toto.1"

here is a usable snippet:

	versions := []string{
		"1.0.0",
		"1.0.0-beta.2",
		"1.0.0-beta.1",
		"1.0.0-alpha.2",
		"1.0.0-alpha.1",
		"1.0.0+toto.1",
	}
	c, _ := semver.NewConstraint("= 1.0.0")
	for _, vs := range versions {
		v, _ := semver.NewVersion(vs)
		fmt.Println(v, c.Check(v))
	}

What I got:

1.0.0 true
1.0.0-beta.2 false
1.0.0-beta.1 false
1.0.0-alpha.2 false
1.0.0-alpha.1 false
1.0.0+toto.1 true

What I was expecting:

1.0.0 true
1.0.0-beta.2 false
1.0.0-beta.1 false
1.0.0-alpha.2 false
1.0.0-alpha.1 false
1.0.0+toto.1 false

If this was the expected behaviour:

  • how do I set a constraint that will work to have only the 1.0.0 matching here?
  • If not possible to match only 1.0.0 here, can we have a == constraint so that a really precise version could be set here?
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

No branches or pull requests

1 participant