Skip to content

Commit

Permalink
fix: check for package compatibility at first
Browse files Browse the repository at this point in the history
  • Loading branch information
oSumAtrIX committed Aug 28, 2023
1 parent 4f2d256 commit 9fe5a0b
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions src/main/kotlin/app/revanced/cli/command/PatchCommand.kt
Original file line number Diff line number Diff line change
Expand Up @@ -241,15 +241,7 @@ internal object PatchCommand : Runnable {
val explicitlyExcluded = excludedPatches.contains(formattedPatchName)
if (explicitlyExcluded) return@patch logger.info("Excluding ${patch.patchName}")

// If the patch is implicitly included, it will be only included if [exclusive] is false.
val implicitlyIncluded = !exclusive && patch.include
// If the patch is explicitly included, it will be included even if [exclusive] is false.
val explicitlyIncluded = includedPatches.contains(formattedPatchName)

val included = implicitlyIncluded || explicitlyIncluded
if (!included) return@patch logger.info("${patch.patchName} excluded by default") // Case 1.

// At last make sure the patch is compatible with the supplied APK files package name and version.
// Make sure the patch is compatible with the supplied APK files package name and version.
patch.compatiblePackages?.let { packages ->
packages.singleOrNull { it.name == packageName }?.let { `package` ->
val matchesVersion = force || `package`.versions.let {
Expand All @@ -269,6 +261,14 @@ internal object PatchCommand : Runnable {
return@let
} ?: logger.fine("$formattedPatchName: No constraint on packages.")

// If the patch is implicitly included, it will be only included if [exclusive] is false.
val implicitlyIncluded = !exclusive && patch.include
// If the patch is explicitly included, it will be included even if [exclusive] is false.
val explicitlyIncluded = includedPatches.contains(formattedPatchName)

val included = implicitlyIncluded || explicitlyIncluded
if (!included) return@patch logger.info("${patch.patchName} excluded by default") // Case 1.

logger.fine("Adding $formattedPatchName")

add(patch)
Expand Down

0 comments on commit 9fe5a0b

Please sign in to comment.