Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/main' into feature/repo-merge
Browse files Browse the repository at this point in the history
  • Loading branch information
Machine-Maker committed Nov 1, 2024
2 parents 8722086 + 6408556 commit b33579b
Show file tree
Hide file tree
Showing 7 changed files with 32 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -177,9 +177,11 @@ abstract class ApplyPaperPatches : ControllableOutputTask() {
git("tag", "-d", "base").runSilently(silenceErr = true)
git("tag", "base").executeSilently()

applyGitPatches(git, target, outputFile, patchDir.path, printOutput.get(), verbose.get())

makeMcDevSrc(layout.cache, sourceMcDevJar.path, mcDevSources.path, outputDir.path, sourceDir, mcDataDir)
try {
applyGitPatches(git, target, outputFile, patchDir.path, printOutput.get(), verbose.get())
} finally {
makeMcDevSrc(layout.cache, sourceMcDevJar.path, mcDevSources.path, outputDir.path, sourceDir, mcDataDir)
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -200,9 +200,14 @@ abstract class CreateBundlerJar : ZippedTask() {
return when (val ident = id.componentIdentifier) {
is ModuleComponentIdentifier -> ModuleId.fromIdentifier(id)
is ProjectComponentIdentifier -> {
val capability = variant.capabilities.first()
val version = capability.version ?: throw PaperweightException("Unknown version for ${capability.group}:${capability.name}")
ModuleId(capability.group, capability.name, version)
val mainCap = variant.attributes.getAttribute(mainCapabilityAttribute)
if (mainCap != null) {
ModuleId.parse(mainCap)
} else {
val capability = variant.capabilities.first()
val version = capability.version ?: throw PaperweightException("Unknown version for ${capability.group}:${capability.name}")
ModuleId(capability.group, capability.name, version)
}
}
else -> throw PaperweightException("Unknown artifact result type: ${ident::class.java.name}")
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ abstract class RebuildGitPatches : ControllableOutputTask() {
git("fetch", "--all", "--prune").runSilently(silenceErr = true)
git(
"format-patch",
"--zero-commit", "--full-index", "--no-signature", "--no-stat", "-N",
"--diff-algorithm=myers", "--zero-commit", "--full-index", "--no-signature", "--no-stat", "-N",
"-o", patchFolder.absolutePathString(),
baseRef.get()
).executeSilently()
Expand Down Expand Up @@ -131,7 +131,7 @@ abstract class RebuildGitPatches : ControllableOutputTask() {
try {
for (patch in patchFiles) {
futures += executor.submit {
val hasNoChanges = git("diff", "--staged", patch.name).getText().lineSequence()
val hasNoChanges = git("diff", "--diff-algorithm=myers", "--staged", patch.name).getText().lineSequence()
.filter { it.startsWith('+') || it.startsWith('-') }
.filterNot { it.startsWith("+++") || it.startsWith("---") }
.all { it.startsWith("+index") || it.startsWith("-index") }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,13 @@ abstract class RemapJar : JavaLauncherTask() {

@TaskAction
fun run() {
if (inputJar.path.absolute().normalize() == outputJar.path.absolute().normalize()) {
throw PaperweightException(
"Invalid configuration, inputJar and outputJar point to the same path: ${inputJar.path}\n" +
"Consider removing customization of output locations, following the default Gradle conventions."
)
}

if (toNamespace.get() != fromNamespace.get()) {
val logFile = layout.cache.resolve(paperTaskOutput("log"))
TinyRemapper.run(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ class PatchApplier(
target.createDirectories()
git("checkout", remappedBranch).executeSilently()
git(
"format-patch", "--zero-commit", "--full-index", "--no-signature", "--no-stat", "-N", "-o",
"format-patch", "--diff-algorith=myers", "--zero-commit", "--full-index", "--no-signature", "--no-stat", "-N", "-o",
target.absolutePathString(), remappedBaseTag
).executeOut()
}
Expand All @@ -114,7 +114,7 @@ class PatchApplier(
}

git("update-index", "--refresh").executeSilently()
if (git("diff-index", "--quiet", "HEAD", "--").runSilently() == 0) {
if (git("diff-index", "--diff-algorithm=myers", "--quiet", "HEAD", "--").runSilently() == 0) {
return git("log", unmappedBranch, "-1", "--pretty=%B").getText().trim() !=
git("log", remappedBranch, "-1", "--pretty=%B").getText().trim()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ import kotlin.io.path.*
import org.cadixdev.lorenz.merge.MergeResult
import org.gradle.api.Project
import org.gradle.api.Task
import org.gradle.api.attributes.Attribute
import org.gradle.api.file.FileCollection
import org.gradle.api.file.FileSystemLocation
import org.gradle.api.file.ProjectLayout
Expand Down Expand Up @@ -423,3 +424,5 @@ fun modifyManifest(path: Path, create: Boolean = true, op: Manifest.() -> Unit)
path.outputStream().buffered().use { mf.write(it) }
}
}

val mainCapabilityAttribute: Attribute<String> = Attribute.of("io.papermc.paperweight.main-capability", String::class.java)
Original file line number Diff line number Diff line change
Expand Up @@ -161,8 +161,10 @@ abstract class PatcherApplyGitPatches : ControllableOutputTask() {
git("tag", "-d", "base").runSilently(silenceErr = true)
git("tag", "base").executeSilently()

applyGitPatches(git, target, output, patchDir.pathOrNull, printOutput.get(), verbose.get())

makeMcDevSrc(layout.cache, sourceMcDevJar.path, mcDevSources.path, outputDir.path, srcDir, dataDir)
try {
applyGitPatches(git, target, output, patchDir.pathOrNull, printOutput.get(), verbose.get())
} finally {
makeMcDevSrc(layout.cache, sourceMcDevJar.path, mcDevSources.path, outputDir.path, srcDir, dataDir)
}
}
}

0 comments on commit b33579b

Please sign in to comment.