VersionHelper: prefer semver compare over list-index (refs #538)#561
VersionHelper: prefer semver compare over list-index (refs #538)#561rainxchzed wants to merge 1 commit intomainfrom
Conversation
…eck. Issue #538: a fresh install of the latest release was incorrectly flagged as a downgrade. Root cause: the previous algorithm used the position of each tag in the release list as the primary heuristic, on the assumption that the list is newest-first by version. GitHub orders releases by `published_at` though, and that ordering diverges from semver ordering as soon as a maintainer republishes an old release, fixes a typo on a tag, or backdates a release. In that case `candidateIndex > currentIndex` flips and the install flow shows a phantom downgrade warning over a perfectly normal upgrade. Switch to scheme-aware compare: when both sides parse as SemVer or CalVer, trust VersionMath.compareVersions (which already handles prefix strip, build-metadata, pre-release ordering, and the build-variant suffix added in #560). List-index is now a secondary fallback used only when at least one input has no parseable scheme (commit-hash tags, ad-hoc strings). Also collapses the duplicate normaliser/comparator implementations into the single source of truth in `core.domain.util.VersionMath`. The public surface of VersionHelper is unchanged, so the only call site (DetailsViewModel.install) needs no updates. Out of scope for this PR (mentioned in issue but separate concerns): - Root-based silent install (would be a new InstallSource alongside Shizuku/Sui/Dhizuku). - UI glitch shown in the second screenshot — needs reproduction steps; tracked separately. Refs #538.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
Walkthrough
ChangesVersionHelper Delegation to VersionMath
Estimated code review effort🎯 4 (Complex) | ⏱️ ~50 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
What this PR fixes
Refs #538.
A fresh install of the latest release was being flagged as a downgrade in the install flow on the details screen.
Root cause
The old
VersionHelper.isDowngradeVersionalgorithm used the position of each tag inallReleasesas the primary heuristic, with semver compare as the fallback. Comment said "releases are newest-first" — but GitHub orders the release feed bypublished_at, not by version. As soon as a maintainer:published_atthan the supposed-latest,the list ordering and the version ordering diverge.
candidateIndex > currentIndexflips even whencandidateis genuinely newer, and the user sees a phantom downgrade warning over a perfectly normal upgrade.Fix
VersionMath.compareVersions(which already handles prefix strip, build-metadata, pre-release ordering, and the build-variant suffix added in Strip build-variant suffix during version normalization (closes #557) #560). The sign of the comparator is authoritative.VersionMath.compareVersions(which itself lex-compares when nothing else parses).Side cleanup
VersionHelperwas carrying its own duplicatenormalizeVersion/compareSemanticVersionsimplementations that drifted from the canonicalVersionMath. Both now delegate. Public API surface is unchanged so the single call site (DetailsViewModel.install) needs no updates.Out of scope (mentioned in issue, tracked separately)
InstallSourcealongside Shizuku / Sui / Dhizuku. Separate feature work.Test plan
Summary by CodeRabbit
Improvements
Documentation