Skip to content

fix: correct version comparison to handle semver and pre-release tags#250

Merged
leggetter merged 1 commit intomainfrom
auto-implement-issue-232
Mar 17, 2026
Merged

fix: correct version comparison to handle semver and pre-release tags#250
leggetter merged 1 commit intomainfrom
auto-implement-issue-232

Conversation

@github-actions
Copy link
Contributor

The CLI's "newer version available" prompt was using a plain string comparison after stripping the v prefix. This caused two bugs:

  1. Numeric component ordering: 1.9.x was considered newer than 1.10.x because "9" > "1" lexicographically.
  2. Pre-release confusion: A GA version like 1.9.1 would be flagged as needing an upgrade to 1.10.0-beta.4 even though that is a pre-release.

How it was solved

Replaced the single-line string comparison in needsToUpgrade with proper semantic version logic:

  • Numeric component comparison — version numbers are split by . and each segment is compared as an integer, so 1.10.0 > 1.9.1 correctly.
  • Pre-release awareness — if the current version is a GA release and the latest is a pre-release, no upgrade is suggested (avoids GA → beta "downgrade"). If the current version is a pre-release, upgrades to either a newer pre-release or a GA release are surfaced correctly.
  • Pre-release ordering — pre-release identifiers (e.g. beta.9 vs beta.10) are compared segment-by-segment with numeric segments compared as integers.

New unit tests cover all the edge cases including the exact scenario from the issue (1.9.1 current, 1.10.0-beta.4 latest → no prompt).

Loading
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

Successfully merging this pull request may close these issues.

1 participant