Skip to content

Commit 1096714

Browse files
committed
Restructure apply check again
1 parent 642c6a8 commit 1096714

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

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

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -67,23 +67,25 @@ abstract class PatchRouletteApply : AbstractPatchRouletteTask() {
6767
Config(listOf(), null, listOf())
6868
}
6969

70-
val reapplyPatches = this.reapplyPatches.getOrElse(false);
71-
if (config.currentPatches.isNotEmpty() && !reapplyPatches) { // Ignore if reapplying
72-
throw PaperweightException("You already selected the patches [${config.currentPatches.joinToString(", ") { it.name }}]!")
73-
}
74-
70+
// Nothing can be applied if the target repo is dirty.
7571
val git = Git(targetDir.path)
7672
val potentiallyDirtyTargetDir = git("status", "--porcelain").getText()
7773
if (potentiallyDirtyTargetDir.isNotEmpty()) {
7874
throw PaperweightException("Target directory is dirty, finish and rebuild previous patches first: [$potentiallyDirtyTargetDir]")
7975
}
8076

81-
if (reapplyPatches) {
77+
// Early opt out if someone is only attempting to re-apply
78+
if (this.reapplyPatches.getOrElse(false)) {
8279
logger.lifecycle("Reapplying ${config.currentPatches.size} currently selected patches")
8380
applyPatches(git, config.currentPatches)
8481
return
8582
}
8683

84+
// Prevent acquiring new patches from roulette if current patches have not been marked as finished yet.
85+
if (config.currentPatches.isNotEmpty()) {
86+
throw PaperweightException("You already selected the patches [${config.currentPatches.joinToString(", ") { it.name }}]!")
87+
}
88+
8789
var tries = 5
8890
var patches = listOf<Path>()
8991
val patchSelectionStrategy = patchSelectionStrategy

0 commit comments

Comments
 (0)