Skip to content

fix: correctly resolve npm dist-tags latest using semver - #415

Open
BethGriggs wants to merge 1 commit into
pulp:mainfrom
BethGriggs:version-matching
Open

fix: correctly resolve npm dist-tags latest using semver#415
BethGriggs wants to merge 1 commit into
pulp:mainfrom
BethGriggs:version-matching

Conversation

@BethGriggs

Copy link
Copy Markdown

Previously, latest was selected using Python's built-in max() on raw version strings, which performs lexicographic comparison (e.g. "9.0.0" > "10.0.0") and did not exclude pre-release versions.

  • Replace lexicographic max(versions) with semver.Version.parse as sort key so that 10.0.0 correctly ranks above 9.0.0
  • Filter out pre-release versions (e.g. 1.0.0-alpha.1) when selecting the latest dist-tag; fall back to all versions only if no stable versions exist
  • Add semver>=3.0.0 as a declared runtime dependency in pyproject.toml
  • Fix extract_package_info() regex to match full semver strings including pre-release and build-metadata suffixes, and make the base_name group non-greedy to correctly split hyphenated package names from their version

📜 Checklist

  • Commits are cleanly separated with meaningful messages (simple features and bug fixes should be squashed to one commit)
  • A changelog entry or entries has been added for any significant changes
  • Follows the Pulp policy on AI Usage
  • (For new features) - User documentation and test coverage has been added

Previously, latest was selected using Python's built-in max() on raw
version strings, which performs lexicographic comparison (e.g.
"9.0.0" > "10.0.0") and did not exclude pre-release versions.

- Parse all version strings once via semver.Version.parse, skipping
  any malformed values, to avoid redundant parsing and ValueError on
  invalid versions in the fallback path
- Filter out pre-release versions (e.g. 1.0.0-alpha.1) when selecting
  the latest dist-tag; fall back to all valid semver versions if no
  stable versions exist
- Add semver>=3.0.0 as a declared runtime dependency in pyproject.toml
- Fix extract_package_info() regex to match full semver strings
  including pre-release and build-metadata suffixes; make base_name
  non-greedy ([^/]+?) to avoid ambiguity on hyphenated package names
  like my-pkg-1.0.0-rc.1.tgz, where a greedy match would consume into
  the version and cause extract_package_info() to return (None, None)

Assisted By: Bob
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant