Skip to content

Commit 64d9127

Browse files
committed
fix: Only set options for filtered patches
This prevents errors when settings required options from patches that are not accepted to `null`.
1 parent e3c5550 commit 64d9127

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

src/main/kotlin/app/revanced/cli/command/PatchCommand.kt

+9-9
Original file line numberDiff line numberDiff line change
@@ -196,13 +196,6 @@ internal object PatchCommand : Runnable {
196196
logger.warning("Unknown input of patches:\n${unknownPatches.joinToString("\n")}")
197197
}
198198

199-
logger.info("Setting patch options")
200-
201-
optionsFile.let {
202-
if (it.exists()) patches.setOptions(it)
203-
else Options.serialize(patches, prettyPrint = true).let(it::writeText)
204-
}
205-
206199
// endregion
207200

208201
Patcher(
@@ -213,11 +206,18 @@ internal object PatchCommand : Runnable {
213206
resourceCachePath.absolutePath,
214207
)
215208
).use { patcher ->
209+
val filteredPatches = patcher.filterPatchSelection(patches).also { patches ->
210+
logger.info("Setting patch options")
211+
212+
if (optionsFile.exists()) patches.setOptions(optionsFile)
213+
else Options.serialize(patches, prettyPrint = true).let(optionsFile::writeText)
214+
}
215+
216216
// region Patch
217217

218218
val patcherResult = patcher.apply {
219219
acceptIntegrations(integrations)
220-
acceptPatches(filterPatchSelection(patches))
220+
acceptPatches(filteredPatches.toList())
221221

222222
// Execute patches.
223223
runBlocking {
@@ -277,7 +277,7 @@ internal object PatchCommand : Runnable {
277277
* @param patches The patches to filter.
278278
* @return The filtered patches.
279279
*/
280-
private fun Patcher.filterPatchSelection(patches: PatchSet) = buildList {
280+
private fun Patcher.filterPatchSelection(patches: PatchSet): PatchSet = buildSet {
281281
val packageName = context.packageMetadata.packageName
282282
val packageVersion = context.packageMetadata.packageVersion
283283

0 commit comments

Comments
 (0)