diff --git a/paperweight-core/src/main/kotlin/io/papermc/paperweight/core/taskcontainers/SoftSpoonTasks.kt b/paperweight-core/src/main/kotlin/io/papermc/paperweight/core/taskcontainers/SoftSpoonTasks.kt index f13e1826..21a8d02f 100644 --- a/paperweight-core/src/main/kotlin/io/papermc/paperweight/core/taskcontainers/SoftSpoonTasks.kt +++ b/paperweight-core/src/main/kotlin/io/papermc/paperweight/core/taskcontainers/SoftSpoonTasks.kt @@ -29,6 +29,7 @@ import io.papermc.paperweight.tasks.mache.RemapJar import io.papermc.paperweight.tasks.softspoon.ApplyFeaturePatches import io.papermc.paperweight.tasks.softspoon.ApplyFilePatches import io.papermc.paperweight.tasks.softspoon.ApplyFilePatchesFuzzy +import io.papermc.paperweight.tasks.softspoon.FixupFilePatches import io.papermc.paperweight.tasks.softspoon.RebuildFilePatches import io.papermc.paperweight.util.* import io.papermc.paperweight.util.constants.* @@ -228,6 +229,20 @@ open class SoftSpoonTasks( dependsOn(rebuildFilePatches, rebuildFeaturePatches) } + val fixupSourcePatches by tasks.registering(FixupFilePatches::class) { + group = "softspoon" + description = "Puts the currently tracked source changes into the file patches commit" + + repo.set(project.ext.serverProject.map { it.layout.projectDirectory.dir("src/vanilla/java") }) + } + + val fixupResourcePatches by tasks.registering(FixupFilePatches::class) { + group = "softspoon" + description = "Puts the currently tracked resource changes into the file patches commit" + + repo.set(project.ext.serverProject.map { it.layout.projectDirectory.dir("src/vanilla/resources") }) + } + fun afterEvaluate() { // load mache mache = this.project.configurations.named(MACHE_CONFIG).get().singleFile.toPath().openZip().use { zip -> diff --git a/paperweight-lib/src/main/kotlin/io/papermc/paperweight/tasks/softspoon/FixupFilePatches.kt b/paperweight-lib/src/main/kotlin/io/papermc/paperweight/tasks/softspoon/FixupFilePatches.kt new file mode 100644 index 00000000..64080413 --- /dev/null +++ b/paperweight-lib/src/main/kotlin/io/papermc/paperweight/tasks/softspoon/FixupFilePatches.kt @@ -0,0 +1,22 @@ +package io.papermc.paperweight.tasks.softspoon + +import io.papermc.paperweight.tasks.* +import io.papermc.paperweight.util.* +import org.gradle.api.file.DirectoryProperty +import org.gradle.api.tasks.InputDirectory +import org.gradle.api.tasks.TaskAction +import org.gradle.api.tasks.UntrackedTask + +@UntrackedTask(because = "Always fixup when requested") +abstract class FixupFilePatches : BaseTask() { + + @get:InputDirectory + abstract val repo: DirectoryProperty + + @TaskAction + fun run() { + val git = Git(repo) + git("commit", "--fixup", "file").executeOut() + git("-c", "sequence.editor=:", "rebase", "-i", "--autosquash", "mache/main").executeOut() + } +}