From f9327a2043f259671fc918b8c64aa41e62485701 Mon Sep 17 00:00:00 2001 From: Lucaskyy Date: Sat, 19 Mar 2022 21:58:31 +0100 Subject: [PATCH] executePatches -> applyPatches, made logback a test dep --- build.gradle.kts | 2 +- src/main/kotlin/net/revanced/patcher/Patcher.kt | 9 ++++----- src/test/kotlin/net/revanced/patcher/PatcherTest.kt | 2 +- 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index f5b5d6d..cb04de2 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -16,8 +16,8 @@ dependencies { implementation("org.ow2.asm:asm-util:9.2") implementation("org.ow2.asm:asm-tree:9.2") implementation("org.ow2.asm:asm-commons:9.2") - implementation("ch.qos.logback:logback-classic:1.2.11") implementation("io.github.microutils:kotlin-logging:2.1.21") + testImplementation("ch.qos.logback:logback-classic:1.2.11") // use your own logger! testImplementation(kotlin("test")) } diff --git a/src/main/kotlin/net/revanced/patcher/Patcher.kt b/src/main/kotlin/net/revanced/patcher/Patcher.kt index 0e0b7fe..0228197 100644 --- a/src/main/kotlin/net/revanced/patcher/Patcher.kt +++ b/src/main/kotlin/net/revanced/patcher/Patcher.kt @@ -2,13 +2,11 @@ package net.revanced.patcher import net.revanced.patcher.cache.Cache import net.revanced.patcher.patch.Patch -import net.revanced.patcher.patch.PatchResult import net.revanced.patcher.resolver.MethodResolver import net.revanced.patcher.signature.Signature import net.revanced.patcher.util.Jar2ASM import java.io.InputStream import java.io.OutputStream -import java.util.jar.JarFile /** * The patcher. (docs WIP) @@ -32,7 +30,7 @@ class Patcher ( this.patches.addAll(patches) } - fun executePatches(): Map> { + fun applyPatches(stopOnError: Boolean = false): Map> { return buildMap { for (patch in patches) { val result: Result = try { @@ -43,11 +41,12 @@ class Patcher ( Result.failure(e) } this[patch.patchName] = result + if (stopOnError && result.isFailure) break } } } - fun save(output: OutputStream) { - + fun saveTo(output: OutputStream) { + } } \ No newline at end of file diff --git a/src/test/kotlin/net/revanced/patcher/PatcherTest.kt b/src/test/kotlin/net/revanced/patcher/PatcherTest.kt index bed05f3..3f01be2 100644 --- a/src/test/kotlin/net/revanced/patcher/PatcherTest.kt +++ b/src/test/kotlin/net/revanced/patcher/PatcherTest.kt @@ -37,7 +37,7 @@ internal class PatcherTest { } ) - val result = patcher.executePatches() + val result = patcher.applyPatches() for ((s, r) in result) { if (r.isFailure) { throw Exception("Patch $s failed", r.exceptionOrNull()!!)