mirror of
https://github.com/revanced/revanced-cli.git
synced 2025-01-26 18:57:31 +01:00
feat: Do not format patch names
This gets rid of the ability to input a patch name in lower camel case. The reason for this is because there may be two distinct patches such as "Some Patch" and "some-patch" with no way to exclude or include either.
This commit is contained in:
parent
50c0f98ce5
commit
80a8d88406
@ -256,31 +256,18 @@ internal object PatchCommand : Runnable {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Filter the patches to be added to the patcher. The filter is based on the following:
|
* Filter the patches to be added to the patcher. The filter is based on the following:
|
||||||
* - [includedPatches] (explicitly included)
|
|
||||||
* - [excludedPatches] (explicitly excluded)
|
|
||||||
* - [exclusive] (only include patches that are explicitly included)
|
|
||||||
* - [force] (ignore patches incompatibility to versions)
|
|
||||||
* - Package name and version of the input APK file (if [force] is false)
|
|
||||||
*
|
*
|
||||||
* @param patches The patches to filter.
|
* @param patches The patches to filter.
|
||||||
* @return The filtered patches.
|
* @return The filtered patches.
|
||||||
*/
|
*/
|
||||||
private fun Patcher.filterPatchSelection(patches: PatchSet) = buildList {
|
private fun Patcher.filterPatchSelection(patches: PatchSet) = buildList {
|
||||||
// TODO: Remove this eventually because
|
|
||||||
// patches named "patch-name" and "patch name" will conflict.
|
|
||||||
fun String.format() = lowercase().replace(" ", "-")
|
|
||||||
|
|
||||||
val formattedExcludedPatches = excludedPatches.map { it.format() }
|
|
||||||
val formattedIncludedPatches = includedPatches.map { it.format() }
|
|
||||||
|
|
||||||
val packageName = context.packageMetadata.packageName
|
val packageName = context.packageMetadata.packageName
|
||||||
val packageVersion = context.packageMetadata.packageVersion
|
val packageVersion = context.packageMetadata.packageVersion
|
||||||
|
|
||||||
patches.forEach patch@{ patch ->
|
patches.forEach patch@{ patch ->
|
||||||
val patchName = patch.name!!
|
val patchName = patch.name!!
|
||||||
val formattedPatchName = patchName.format()
|
|
||||||
|
|
||||||
val explicitlyExcluded = formattedExcludedPatches.contains(formattedPatchName)
|
val explicitlyExcluded = excludedPatches.contains(patchName)
|
||||||
if (explicitlyExcluded) return@patch logger.info("Excluding $patchName")
|
if (explicitlyExcluded) return@patch logger.info("Excluding $patchName")
|
||||||
|
|
||||||
// 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.
|
||||||
@ -303,17 +290,17 @@ internal object PatchCommand : Runnable {
|
|||||||
+ packages.joinToString(", ") { `package` -> `package`.name })
|
+ packages.joinToString(", ") { `package` -> `package`.name })
|
||||||
|
|
||||||
return@let
|
return@let
|
||||||
} ?: logger.fine("$formattedPatchName: No constraint on packages.")
|
} ?: logger.fine("$patchName has no constraint on packages.")
|
||||||
|
|
||||||
// If the patch is implicitly used, it will be only included if [exclusive] is false.
|
// If the patch is implicitly used, it will be only included if [exclusive] is false.
|
||||||
val implicitlyIncluded = !exclusive && patch.use
|
val implicitlyIncluded = !exclusive && patch.use
|
||||||
// If the patch is explicitly used, it will be included even if [exclusive] is false.
|
// If the patch is explicitly used, it will be included even if [exclusive] is false.
|
||||||
val explicitlyIncluded = formattedIncludedPatches.contains(formattedPatchName)
|
val explicitlyIncluded = includedPatches.contains(patchName)
|
||||||
|
|
||||||
val included = implicitlyIncluded || explicitlyIncluded
|
val included = implicitlyIncluded || explicitlyIncluded
|
||||||
if (!included) return@patch logger.info("$patchName excluded by default") // Case 1.
|
if (!included) return@patch logger.info("$patchName excluded") // Case 1.
|
||||||
|
|
||||||
logger.fine("Adding $formattedPatchName")
|
logger.fine("Adding $patchName")
|
||||||
|
|
||||||
add(patch)
|
add(patch)
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user