Compare APK versions with apk-tools tokenization - #45
Merged
Conversation
The apk and alpine schemes previously delegated to the Gentoo comparator, which does not recognise the VCS suffixes (_cvs, _svn, _git, _hg), commit-hash markers (~<hex>), or apk-tools' leading-zero and uint64 rules. Port the tokenizer from apk-tools src/version.c at 900a3f5 and drive it from the vendored test/unit/version.data fixture (738 comparisons, 31 validity checks). APK validation and prerelease classification now use the same tokenizer instead of Gentoo's.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The
apkandalpineschemes previously delegated to the Gentoo comparator, which does not recognise the VCS suffixes (_cvs,_svn,_git,_hg), commit-hash markers (~<hex>), or apk-tools' leading-zero and uint64 numeric rules. That made1.0_gitcompare equal to1.0and1.0_cvsequal to1.0_svn.This ports the tokenizer from apk-tools
src/version.cat900a3f5280bfad7ea22eda7de46d0d4c0c9ce8f2and vendors that revision'stest/unit/version.dataas a fixture. The test parses it directly and asserts all 738 comparison lines and 31 validity lines throughCompareWithSchemeandValidWithScheme; the fuzzy-match section is skipped since vers does not modelapk_version_match.APK validation and prerelease classification now use the same tokenizer, so
ValidWithScheme("0.1bc", "apk")is false andIsPrereleaseWithScheme("1.0_git20240101", "apk")is false while_alpha/_beta/_pre/_rcremain prerelease.The vendored fixture is GPL-2.0-only test data, recorded in
testdata/local/provenance.jsonalongside the existing dpkg and rpm fixtures under the same licence family.