Skip to content

Commit

Permalink
add fixup(Re)sourcePatches tasks
Browse files Browse the repository at this point in the history
  • Loading branch information
MiniDigger committed Nov 1, 2024
1 parent fd39a0d commit 63d0471
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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.*
Expand Down Expand Up @@ -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 ->
Expand Down
Original file line number Diff line number Diff line change
@@ -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()
}
}

0 comments on commit 63d0471

Please sign in to comment.