Skip to content

Commit 7a126d6

Browse files
committed
Rename props and fix file separators properly
1 parent 2cdc18a commit 7a126d6

File tree

9 files changed

+21
-22
lines changed

9 files changed

+21
-22
lines changed

paperweight-core/src/main/kotlin/io/papermc/paperweight/core/PaperweightCore.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ abstract class PaperweightCore : Plugin<Project> {
200200
additionalRemote = layout.cache.resolve(
201201
"$OLD_PAPER_PATH/${coreExt.updatingMinecraft.oldPaperCommit.get()}/paper-server/src/minecraft/java"
202202
).absolutePathString()
203-
rejectsForDiffPatches = false
203+
emitRejects = false
204204
}
205205

206206
PatchRouletteTasks(

paperweight-core/src/main/kotlin/io/papermc/paperweight/core/taskcontainers/MinecraftPatchingTasks.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ class MinecraftPatchingTasks(
8282
output.set(outputSrc)
8383
}
8484
patches.set(sourcePatchDir.fileExists(project))
85-
rejects.set(rejectsDir)
85+
rejectsDir.set(rejectsDir)
8686
gitFilePatches.set(this@MinecraftPatchingTasks.gitFilePatches)
8787
identifier = configName
8888
}

paperweight-core/src/main/kotlin/io/papermc/paperweight/core/taskcontainers/PatchingTasks.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ class PatchingTasks(
6767
output.set(outputDir)
6868
}
6969
patches.set(filePatchDir.fileExists(project))
70-
rejects.set(rejectsDir)
70+
rejectsDir.set(rejectsDir)
7171
gitFilePatches.set(this@PatchingTasks.gitFilePatches)
7272
baseRef.set("base")
7373
identifier = "$forkName $patchSetName"

paperweight-core/src/main/kotlin/io/papermc/paperweight/core/tasks/patching/ApplyFilePatches.kt

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ abstract class ApplyFilePatches : BaseTask() {
6464
abstract val patches: DirectoryProperty
6565

6666
@get:Internal
67-
abstract val rejects: DirectoryProperty
67+
abstract val rejectsDir: DirectoryProperty
6868

6969
@get:Optional
7070
@get:Input
@@ -90,15 +90,15 @@ abstract class ApplyFilePatches : BaseTask() {
9090
abstract val moveFailedGitPatchesToRejects: Property<Boolean>
9191

9292
@get:Internal
93-
abstract val rejectsForDiffPatches: Property<Boolean>
93+
abstract val emitRejects: Property<Boolean>
9494

9595
init {
9696
run {
9797
verbose.convention(false)
9898
gitFilePatches.convention(false)
9999
additionalRemoteName.convention("old")
100100
moveFailedGitPatchesToRejects.convention(false)
101-
rejectsForDiffPatches.convention(true)
101+
emitRejects.convention(true)
102102
}
103103
}
104104

@@ -171,7 +171,7 @@ abstract class ApplyFilePatches : BaseTask() {
171171
private fun applyWithGit(outputPath: Path): Int {
172172
val git = Git(outputPath)
173173
val patchFiles = patches.path.filesMatchingRecursive("*.patch")
174-
if (moveFailedGitPatchesToRejects.get() && rejects.isPresent) {
174+
if (moveFailedGitPatchesToRejects.get() && rejectsDir.isPresent) {
175175
patchFiles.forEach { patch ->
176176
val patchPathFromGit = outputPath.relativize(patch)
177177
val responseCode =
@@ -193,7 +193,7 @@ abstract class ApplyFilePatches : BaseTask() {
193193
git("restore", failedFile.pathString).executeSilently(silenceOut = !verbose.get(), silenceErr = !verbose.get())
194194
}
195195

196-
val rejectFile = rejects.path.resolve(relativePatch)
196+
val rejectFile = rejectsDir.path.resolve(relativePatch)
197197
patch.moveTo(rejectFile.createParentDirectories(), overwrite = true)
198198
}
199199
}
@@ -223,8 +223,8 @@ abstract class ApplyFilePatches : BaseTask() {
223223
.summary(verbose.get())
224224
.lineEnding("\n")
225225
.ignorePrefix(".git")
226-
if (rejects.isPresent && rejectsForDiffPatches.get()) {
227-
builder.rejectsPath(rejects.path)
226+
if (rejectsDir.isPresent && emitRejects.get()) {
227+
builder.rejectsPath(rejectsDir.path)
228228
}
229229

230230
val result = builder.build().operate()

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

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ abstract class AbstractPatchRouletteTask : BaseTask() {
127127
fun setPatches(paths: List<String>) {
128128
val response = httpClient().send(
129129
HttpRequest.newBuilder()
130-
.POST(HttpRequest.BodyPublishers.ofString(gson.toJson(SetPatches(paths.normalisePathSeparators(), minecraftVersion.get()))))
130+
.POST(HttpRequest.BodyPublishers.ofString(gson.toJson(SetPatches(paths, minecraftVersion.get()))))
131131
.uri(URI.create(endpoint.get() + "/set-patches"))
132132
.auth()
133133
.contentTypeApplicationJson()
@@ -161,7 +161,7 @@ abstract class AbstractPatchRouletteTask : BaseTask() {
161161
fun startPatches(paths: List<String>): List<String> {
162162
val response = httpClient().send(
163163
HttpRequest.newBuilder()
164-
.POST(HttpRequest.BodyPublishers.ofString(gson.toJson(PatchesInfo(paths.normalisePathSeparators(), minecraftVersion.get()))))
164+
.POST(HttpRequest.BodyPublishers.ofString(gson.toJson(PatchesInfo(paths, minecraftVersion.get()))))
165165
.uri(URI.create(endpoint.get() + "/start-patches"))
166166
.auth()
167167
.contentTypeApplicationJson()
@@ -181,7 +181,7 @@ abstract class AbstractPatchRouletteTask : BaseTask() {
181181
fun completePatch(path: String) {
182182
val response = httpClient().send(
183183
HttpRequest.newBuilder()
184-
.POST(HttpRequest.BodyPublishers.ofString(gson.toJson(PatchInfo(path.normalisePathSeparators(), minecraftVersion.get()))))
184+
.POST(HttpRequest.BodyPublishers.ofString(gson.toJson(PatchInfo(path, minecraftVersion.get()))))
185185
.uri(URI.create(endpoint.get() + "/complete-patch"))
186186
.auth()
187187
.contentTypeApplicationJson()
@@ -197,7 +197,7 @@ abstract class AbstractPatchRouletteTask : BaseTask() {
197197
fun cancelPatch(path: String) {
198198
val response = httpClient().send(
199199
HttpRequest.newBuilder()
200-
.POST(HttpRequest.BodyPublishers.ofString(gson.toJson(PatchInfo(path.normalisePathSeparators(), minecraftVersion.get()))))
200+
.POST(HttpRequest.BodyPublishers.ofString(gson.toJson(PatchInfo(path, minecraftVersion.get()))))
201201
.uri(URI.create(endpoint.get() + "/cancel-patch"))
202202
.auth()
203203
.contentTypeApplicationJson()
@@ -210,6 +210,3 @@ abstract class AbstractPatchRouletteTask : BaseTask() {
210210
logger.lifecycle("Cancelled patch $path")
211211
}
212212
}
213-
214-
private fun String.normalisePathSeparators(): String = replace("\\", "/")
215-
private fun List<String>.normalisePathSeparators(): List<String> = map { it.replace("\\", "/") }

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ abstract class PatchRouletteApply : AbstractPatchRouletteTask() {
124124
}
125125

126126
try {
127-
val startedPatches = startPatches(patches.map { it.pathString })
127+
val startedPatches = startPatches(patches.map { it.invariantSeparatorsPathString })
128128
this.config.path.writeText(gson.toJson(config.copy(currentPatches = patches)))
129129
applyPatches(git, startedPatches.map { Path(it) })
130130
break

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,15 +52,17 @@ abstract class PatchRouletteCancel : AbstractPatchRouletteTask() {
5252
throw PaperweightException("No current patch in config")
5353
}
5454

55-
val patchesToCancel = if (!patch.isPresent) config.currentPatches else {
55+
val patchesToCancel = if (!patch.isPresent) {
56+
config.currentPatches
57+
} else {
5658
if (!config.currentPatches.contains(Path(patch.get()))) {
5759
throw PaperweightException("Cannot cancel patch ${patch.get()} as it isn't currently being worked on!")
5860
}
5961

6062
listOf(Path(patch.get()))
6163
}
6264

63-
patchesToCancel.forEach { cancelPatch(it.pathString) }
65+
patchesToCancel.forEach { cancelPatch(it.invariantSeparatorsPathString) }
6466
this.config.path.writeText(gson.toJson(config.copy(currentPatches = (config.currentPatches - patchesToCancel.toSet()))))
6567
}
6668
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ abstract class PatchRouletteFinish : AbstractPatchRouletteTask() {
6363

6464
// TODO: Do we want to fixup file patches & rebuild here as well?
6565
config.currentPatches.forEach {
66-
completePatch(it.pathString)
66+
completePatch(it.invariantSeparatorsPathString)
6767
patchDir.path.resolve(it).deleteIfExists() // todo git rm
6868
}
6969
this.config.path.writeText(gson.toJson(config.copy(currentPatches = listOf())))

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ abstract class ShowPatchRouletteList : AbstractPatchRouletteTask() {
4545
abstract val pathFilter: Property<String>
4646

4747
override fun run() {
48-
var results = 0;
48+
var results = 0
4949

5050
logger.lifecycle("| Status | User | Path ")
5151
getAllPatches().forEach { patch ->

0 commit comments

Comments
 (0)