fix(arcup): honor SemVer prerelease precedence in version_gt (fixes #205)#212
fix(arcup): honor SemVer prerelease precedence in version_gt (fixes #205)#212danilaverbena wants to merge 1 commit into
Conversation
version_gt stripped the prerelease suffix from both operands before comparing, so versions differing only in prerelease (e.g. 0.3.0 vs 0.3.0-rc.1) compared as equal and the installer's self-update check failed to see a stable release as newer than a prerelease. Implement SemVer section 11 precedence: compare core numerically, then apply prerelease rules (no-prerelease outranks prerelease; dot-separated identifiers compared numerically/lexically; more identifiers outrank fewer). Fixes circlefin#205.
|
Good fix — the bug is real and the implementation is substantially correct. A few observations: Correctness checkThe two reported cases from #205 both work correctly with the new code:
The full SemVer §11.4 precedence chain also holds:
One subtle issue:
|
Problem (fixes #205)
version_gt()strips the prerelease suffix from both operands before comparing:So any prerelease information is discarded and versions that differ only in their prerelease compare as equal:
version_gt "0.3.0" "0.3.0-rc.1"returns non-zero → the stable release is not seen as newer than its release candidate.version_gt "0.3.0-rc.2" "0.3.0-rc.1"also returns non-zero → a newer RC is not detected.Because
version_gtdrives the installer's self-update checks (arcup/arcuplines ~413-430 and ~454-462),arcupfails to recognise a stable release as an upgrade over a previously installed prerelease.Fix
Implement SemVer precedence (semver.org §11) in
version_gt:major.minor.patchcore and its prerelease, and drop build metadata (+...), which is ignored for precedence.Testing
Verified with a local harness covering the reported cases plus the full precedence chain from the SemVer spec (§11.4):
All 18 assertions pass, including the two bug reproductions from the issue, existing core-version comparisons, and build-metadata being ignored.
bash -nclean; behaviour for plainmajor.minor.patchinputs is unchanged.Scope: single self-contained function in
arcup/arcup; no other changes.