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

NpmVeresionRange is giving incorrect version range sequence for prerelease caret range #117

Closed
keshav-space opened this issue Aug 30, 2023 · 0 comments · Fixed by #120
Closed
Labels
bug Something isn't working

Comments

@keshav-space
Copy link
Member

keshav-space commented Aug 30, 2023

NpmVeresionRange is giving incorrect version range sequence for prerelease caret range

>>> from univers.version_range import NpmVersionRange
>>> from univers.versions import SemverVersion
>>> range = NpmVersionRange.from_native("^1.2.3-beta.2")
>>> str(range)
'vers:npm/>=1.2.3-beta.2|>=1.2.3|<1.2.4|<2.0.0'
>>> SemverVersion("1.2.3-beta.3") in range
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "../univers/src/univers/version_range.py", line 224, in __contains__
    return contains_version(version, self.constraints)
  File "../univers/src/univers/version_constraint.py", line 542, in contains_version
    raise Exception(f"Invalid constraints sequence: {constraints }")
Exception: Invalid constraints sequence: [VersionConstraint(comparator='>=', version=SemverVersion(string='1.2.3-beta.2')), VersionConstraint(comparator='>=', version=SemverVersion(string='1.2.3')), VersionConstraint(comparator='<', version=SemverVersion(string='1.2.4')), VersionConstraint(comparator='<', version=SemverVersion(string='2.0.0'))]

The correct sequence of constraints should be

'vers:npm/>=1.2.3-beta.2|<2.0.0'
@keshav-space keshav-space added the bug Something isn't working label Aug 30, 2023
@keshav-space keshav-space changed the title Incorect handling of prerelease caret range in NpmVersionRange.from_native NpmVeresionRange is giving incorrect version range sequence for prerelease caret range Sep 1, 2023
keshav-space added a commit that referenced this issue Sep 6, 2023
- Don't use `python-semanticversion` for parsing the npm caret range:
    it's returning incorrect vers range for the prerelease caret range expressions.
- Issue #117

Signed-off-by: Keshav Priyadarshi <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant