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

Unexpected results comparing with SemVersion.Satisfies #82

Closed
devklick opened this issue Apr 28, 2024 · 1 comment
Closed

Unexpected results comparing with SemVersion.Satisfies #82

devklick opened this issue Apr 28, 2024 · 1 comment

Comments

@devklick
Copy link

I'm expecting version 1.2.3-alpha to satisfy the range < 1.2.4, but that doesn't seem to be the case.

I'm not sure if the < part of this is specific to npm or part of the underlying semver spec, but both of the following return false.

SemVersion.Parse("1.2.3-alpha").SatisfiesNpm("< 1.2.4"); // false
SemVersion.Parse("1.2.3-alpha").Satisfies(SemVersionRange.Parse("< 1.2.4")); // false

The only thing I can to make this work is use SatisfiesNpm and pass in includeAllPrerelease: true. IMO this shouldn't be necessary; regardless of the pre-release flag, 1.2.3 is definitely less than 1.2.4.

SemVersion.Parse("1.2.3-alpha").SatisfiesNpm("< 1.2.4", includeAllPrerelease: true); // true

Is this functioning as intended? I've read the description for this parameter a couple of times and I'm still struggling to get my head around exactly what it's intended to do:

includeAllPrerelease:
Whether to include all prerelease versions satisfying the bounds in the range
or to only include prerelease versions when it matches a bound that explicitly
includes prerelease versions.

@WalkerCodeRanger
Copy link
Owner

This is the intended and expected behavior. This follows the npm convention, which other systems follow as well. This behavior is documented in the Prerelease Versions section of the page that explains the range syntax.

I agree with you that it isn't obvious that this behavior should be the default. However, it does make sense in the context of package managers where one prefers not to include prerelease versions by accident. Also, the default behavior would be very difficult to achieve without a special mode for it.

Setting includeAllPrerelease to true is the correct thing to do if you want those versions to match. If you have suggestions for how to clarify the doc comments while keeping them fairly short and readable, let me know.

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

2 participants