Skip to content

Commit cc1348f

Browse files
committed
Correctly update config on single patch cancel
1 parent 1096714 commit cc1348f

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

paperweight-core/src/main/kotlin/io/papermc/paperweight/core/tasks/patchroulette/PatchRouletteCancel.kt

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,6 @@ abstract class PatchRouletteCancel : AbstractPatchRouletteTask() {
4343
abstract val patch: Property<String>
4444

4545
override fun run() {
46-
if (patch.isPresent) {
47-
cancelPatch(patch.get())
48-
return
49-
}
50-
5146
val config = if (config.path.isRegularFile()) {
5247
gson.fromJson<PatchRouletteApply.Config>(config.path)
5348
} else {
@@ -57,7 +52,15 @@ abstract class PatchRouletteCancel : AbstractPatchRouletteTask() {
5752
throw PaperweightException("No current patch in config")
5853
}
5954

60-
config.currentPatches.forEach { cancelPatch(it.pathString) }
61-
this.config.path.writeText(gson.toJson(config.copy(currentPatches = listOf())))
55+
val patchesToCancel = if (!patch.isPresent) config.currentPatches else {
56+
if (!config.currentPatches.contains(Path(patch.get()))) {
57+
throw PaperweightException("Cannot cancel patch ${patch.get()} as it isn't currently being worked on!")
58+
}
59+
60+
listOf(Path(patch.get()))
61+
}
62+
63+
patchesToCancel.forEach { cancelPatch(it.pathString) }
64+
this.config.path.writeText(gson.toJson(config.copy(currentPatches = (config.currentPatches - patchesToCancel.toSet()))))
6265
}
6366
}

0 commit comments

Comments
 (0)