fix: Only set options for filtered patches

This prevents errors when settings required options from patches that are not accepted to `null`.
This commit is contained in:
oSumAtrIX 2023-10-04 04:18:31 +02:00
parent e3c55507cf
commit 64d9127291
No known key found for this signature in database
GPG Key ID: A9B3094ACDB604B4

View File

@ -196,13 +196,6 @@ internal object PatchCommand : Runnable {
logger.warning("Unknown input of patches:\n${unknownPatches.joinToString("\n")}")
}
logger.info("Setting patch options")
optionsFile.let {
if (it.exists()) patches.setOptions(it)
else Options.serialize(patches, prettyPrint = true).let(it::writeText)
}
// endregion
Patcher(
@ -213,11 +206,18 @@ internal object PatchCommand : Runnable {
resourceCachePath.absolutePath,
)
).use { patcher ->
val filteredPatches = patcher.filterPatchSelection(patches).also { patches ->
logger.info("Setting patch options")
if (optionsFile.exists()) patches.setOptions(optionsFile)
else Options.serialize(patches, prettyPrint = true).let(optionsFile::writeText)
}
// region Patch
val patcherResult = patcher.apply {
acceptIntegrations(integrations)
acceptPatches(filterPatchSelection(patches))
acceptPatches(filteredPatches.toList())
// Execute patches.
runBlocking {
@ -277,7 +277,7 @@ internal object PatchCommand : Runnable {
* @param patches The patches to filter.
* @return The filtered patches.
*/
private fun Patcher.filterPatchSelection(patches: PatchSet) = buildList {
private fun Patcher.filterPatchSelection(patches: PatchSet): PatchSet = buildSet {
val packageName = context.packageMetadata.packageName
val packageVersion = context.packageMetadata.packageVersion