From 7ded89ec4a2e1d6225cd7a70e0389560c44fe521 Mon Sep 17 00:00:00 2001 From: Jake Potrebic Date: Wed, 3 Apr 2024 18:16:50 -0700 Subject: [PATCH] revert back to using original directory names --- .../papermc/sculptor/root/tasks/CopyVersion.kt | 11 ++++------- .../sculptor/root/tasks/MigrateVersion.kt | 17 +++++++---------- .../papermc/sculptor/root/tasks/OpenVersion.kt | 3 +-- .../kotlin/io/papermc/sculptor/root/util.kt | 3 --- 4 files changed, 12 insertions(+), 22 deletions(-) delete mode 100644 sculptor-root/src/main/kotlin/io/papermc/sculptor/root/util.kt diff --git a/sculptor-root/src/main/kotlin/io/papermc/sculptor/root/tasks/CopyVersion.kt b/sculptor-root/src/main/kotlin/io/papermc/sculptor/root/tasks/CopyVersion.kt index 220e3b1..bb5d598 100644 --- a/sculptor-root/src/main/kotlin/io/papermc/sculptor/root/tasks/CopyVersion.kt +++ b/sculptor-root/src/main/kotlin/io/papermc/sculptor/root/tasks/CopyVersion.kt @@ -1,6 +1,5 @@ package io.papermc.sculptor.root.tasks -import io.papermc.sculptor.root.formatVersion import io.papermc.sculptor.shared.util.convertToPath import javax.inject.Inject import kotlin.io.path.copyTo @@ -37,16 +36,14 @@ abstract class CopyVersion : DefaultTask() { val projDir = layout.projectDirectory.convertToPath() val versionsDir = projDir.resolve("versions") - val fromFolder = formatVersion(from) - val fromDir = versionsDir.resolve(fromFolder) - val toFolder = formatVersion(to) - val toDir = versionsDir.resolve(toFolder) + val fromDir = versionsDir.resolve(from) + val toDir = versionsDir.resolve(to) if (fromDir.notExists()) { - throw Exception("--from-version directory does not exist: $fromFolder") + throw Exception("--from-version directory does not exist: $from") } if (toDir.exists()) { - throw Exception("Cannot migrate version, target already exists: $toFolder") + throw Exception("Cannot migrate version, target already exists: $to") } toDir.createDirectories() diff --git a/sculptor-root/src/main/kotlin/io/papermc/sculptor/root/tasks/MigrateVersion.kt b/sculptor-root/src/main/kotlin/io/papermc/sculptor/root/tasks/MigrateVersion.kt index 6826aee..8a142d1 100644 --- a/sculptor-root/src/main/kotlin/io/papermc/sculptor/root/tasks/MigrateVersion.kt +++ b/sculptor-root/src/main/kotlin/io/papermc/sculptor/root/tasks/MigrateVersion.kt @@ -1,6 +1,5 @@ package io.papermc.sculptor.root.tasks -import io.papermc.sculptor.root.formatVersion import io.papermc.sculptor.shared.util.convertToPath import java.nio.file.Path import javax.inject.Inject @@ -42,20 +41,18 @@ abstract class MigrateVersion : DefaultTask() { val projDir = layout.projectDirectory.convertToPath() val versionsDir = projDir.resolve("versions") - val fromFolder = formatVersion(from) - val fromDir = versionsDir.resolve(fromFolder) - val toFolder = formatVersion(to) - val toDir = versionsDir.resolve(toFolder) + val fromDir = versionsDir.resolve(from) + val toDir = versionsDir.resolve(to) if (fromDir.notExists()) { - throw Exception("--from-version directory does not exist: $fromFolder") + throw Exception("--from-version directory does not exist: $from") } if (toDir.exists()) { - throw Exception("Cannot migrate version, target already exists: $toFolder") + throw Exception("Cannot migrate version, target already exists: $to") } // first we need to modify the `.gitignore` so everything we do gets tracked by git properly - modifyGitIgnoreFile(toFolder) + modifyGitIgnoreFile(to) toDir.createDirectories() fromDir.resolve("patches").copyToRecursively(toDir.resolve("patches"), followLinks = false, overwrite = false) @@ -68,11 +65,11 @@ abstract class MigrateVersion : DefaultTask() { val git = Git.open(projDir.toFile()) git.rm() .setCached(true) - .addFilepattern("versions/$fromFolder") + .addFilepattern("versions/$from") .call() git.add() - .addFilepattern("versions/$toFolder") + .addFilepattern("versions/$to") .addFilepattern(".gitignore") .call() } diff --git a/sculptor-root/src/main/kotlin/io/papermc/sculptor/root/tasks/OpenVersion.kt b/sculptor-root/src/main/kotlin/io/papermc/sculptor/root/tasks/OpenVersion.kt index 4dab52d..1518c08 100644 --- a/sculptor-root/src/main/kotlin/io/papermc/sculptor/root/tasks/OpenVersion.kt +++ b/sculptor-root/src/main/kotlin/io/papermc/sculptor/root/tasks/OpenVersion.kt @@ -1,6 +1,5 @@ package io.papermc.sculptor.root.tasks -import io.papermc.sculptor.root.formatVersion import io.papermc.sculptor.shared.util.HashingAlgorithm import io.papermc.sculptor.shared.util.asHexString import io.papermc.sculptor.shared.util.convertToPath @@ -105,7 +104,7 @@ abstract class OpenVersion : DefaultTask() { val thisVersionName = if (directoryName.isPresent) { directoryName.get() } else { - formatVersion(macheMeta.minecraftVersion) + macheMeta.minecraftVersion } val outputDir = versionsDirectory.resolve(thisVersionName) diff --git a/sculptor-root/src/main/kotlin/io/papermc/sculptor/root/util.kt b/sculptor-root/src/main/kotlin/io/papermc/sculptor/root/util.kt deleted file mode 100644 index c20deb0..0000000 --- a/sculptor-root/src/main/kotlin/io/papermc/sculptor/root/util.kt +++ /dev/null @@ -1,3 +0,0 @@ -package io.papermc.sculptor.root - -fun formatVersion(version: String) = "v" + version.replace(".", "_")