Skip to content

fix: Union version codes across every compatibility entry in the list commands - #340

Closed
SysAdminDoc wants to merge 2 commits into
MorpheApp:devfrom
SysAdminDoc:fix/union-version-codes-in-list-commands
Closed

SysAdminDoc wants to merge 2 commits into
MorpheApp:devfrom
SysAdminDoc:fix/union-version-codes-in-list-commands

Conversation

@SysAdminDoc

Copy link
Copy Markdown

A patch can name one package and version through several compatibility entries, one per accepted build, which is how a bundle handles apps that ship several arm64-only releases under a single version string. versionCodesFor in PatchExtensions.kt read only the first target it found with codes for that version, so list-versions and list-patches would print a single build's codes and quietly drop the rest.

The GUI side already handles this correctly: both PatchService.toGuiPatch() and SupportedAppExtractor union build codes across every entry, with an entry that names no codes winning over anything already collected. This brings versionCodesFor in line with that, unioning per ABI across every matching target and, for the Iterable<Patch<*>> overload, across every patch too. The return type moved from Map<SupportedAbi, Int> to Map<SupportedAbi, Set<Int>> to hold more than one code per ABI, so I updated the two list-versions/list-patches call sites to print the codes for an ABI joined with a slash.

Added PatchExtensionsTest covering the union across compatibility entries within one patch, across separate patches, and the plain "no codes declared" case.

Ran:

gradlew.bat test

All unit tests pass.

… commands

versionCodesFor read only the first target it found with codes for a
version, so list-versions and list-patches would show a single accepted
build's codes and silently drop the rest when a patch names the version
through more than one compatibility entry, one per build.

Union the codes per ABI across every matching target and patch instead.
The GUI side (SupportedAppExtractor, PatchService) already merges this
way; this brings the CLI listing helper in line with it.
Move the per-ABI version code union out of versionCodesFor and into
Iterable<Compatibility>.unionVersionCodes in the engine package, so the
CLI's list commands and the GUI's PatchService.toGuiPatch() call the
same function instead of each doing their own union. Removes the
duplicated groupBy/mapValues logic PatchService had for flattening
codes per version.
@SysAdminDoc

Copy link
Copy Markdown
Author

Done. The union now lives in one place: Iterable<Compatibility>.unionVersionCodes() in app/morphe/engine/PatchExtensions.kt. Patch<*>.versionCodesFor() just delegates to it, and PatchService.toGuiPatch() calls the same function instead of running its own groupBy/flatten pass to build versionBuildCodes. CLI and GUI are on the same code now.

Added a test for the new function's own shape (a raw List<Compatibility>, which is how the GUI calls it) alongside the existing ones. Full test suite passes, BuildCodeSupportTest included.

@LisoUseInAIKyrios

Copy link
Copy Markdown
Contributor

I agree with the reasons listed in MorpheApp/morphe-manager#1052 (comment)

If this change is made, it should be made to patcher first so CLI and Manager are in unison with the behavior.

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.

2 participants