-
-
Notifications
You must be signed in to change notification settings - Fork 131
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
Unable to match version range with pre-releases #323
Comments
I'm having a similar issue, I have a version req that is |
@gabrik fn version_matches(version: &semver::Version, req: &semver::VersionReq) -> bool {
if req.matches(version) {
return true;
}
// This custom matching logic is needed, because semver cannot compare different version with pre-release tags
let mut version_without_pre = version.clone();
version_without_pre.pre = "".parse().unwrap();
for comp in &req.comparators {
if comp.matches(version) {
continue;
}
// If major & minor & patch are the same, this means there is a mismatch on the pre-release tag
if comp.major == version.major
&& comp.minor.is_some_and(|m| m == version.minor)
&& comp.patch.is_some_and(|p| p == version.patch)
{
return false;
}
// Otherwise, compare without pre-release tags
let mut comp_without_pre = comp.clone();
comp_without_pre.pre = "".parse().unwrap();
if !comp_without_pre.matches(&version_without_pre) {
return false;
}
}
true
} |
I see, I think I'm going to do the same thing, thank you @Wiezzel |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I am trying to match all versions >=1.0.0 and <2.0.0, including pre-release versions. Unfortunately,
>=1.0.0-rc, <2.0.0-rc1
doesn't do the trick, as pre-releases only match if some comparator has exactly the same major, minor or patch. Is it even possible to specify this kind of dependency?The text was updated successfully, but these errors were encountered: