Skip to content

Commit

Permalink
revert back to using original directory names
Browse files Browse the repository at this point in the history
  • Loading branch information
Machine-Maker authored and MiniDigger committed Apr 4, 2024
1 parent 79e13a2 commit 7ded89e
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 22 deletions.
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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()
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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)
Expand All @@ -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()
}
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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)
Expand Down

This file was deleted.

0 comments on commit 7ded89e

Please sign in to comment.