Skip to content

Commit 9fdadab

Browse files
committed
fix RebuildFilePatchesTest by setting up the git hook
1 parent 1268ba1 commit 9fdadab

File tree

3 files changed

+15
-3
lines changed

3 files changed

+15
-3
lines changed

paperweight-lib/src/main/kotlin/io/papermc/paperweight/tasks/softspoon/RebuildFilePatches.kt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,9 +127,11 @@ abstract class RebuildFilePatches : BaseTask() {
127127
}
128128

129129
if (filesWithNewAts.isNotEmpty()) {
130+
git("status").executeOut()
131+
git("diff").executeOut()
130132
// we removed the comment, we need to commit this
131-
git("add", ".").executeSilently(silenceErr = true)
132-
git("commit", "--amend", "--no-edit").executeSilently(silenceErr = true)
133+
git("add", ".").executeOut()
134+
git("commit", "--amend", "--no-edit").executeOut()
133135
}
134136

135137
// rebuild patches

paperweight-lib/src/test/kotlin/io/papermc/paperweight/tasks/TaskTest.kt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,13 @@ open class TaskTest {
114114
git.close()
115115
}
116116

117+
fun setupGitHook(repo: File) {
118+
val hook = repo.toPath().resolve(".git/hooks/post-rewrite")
119+
hook.parent.createDirectories()
120+
hook.writeText(javaClass.getResource("/post-rewrite.sh")!!.readText())
121+
hook.toFile().setExecutable(true)
122+
}
123+
117124
fun createZip(tempDir: Path, testResource: Path, zipName: String, vararg fileNames: String,): Path {
118125
val targetZip = tempDir.resolve(zipName)
119126

paperweight-lib/src/test/kotlin/io/papermc/paperweight/tasks/softspoon/RebuildFilePatchesTest.kt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ import java.nio.file.Path
2727
import kotlin.test.BeforeTest
2828
import kotlin.test.Test
2929
import org.gradle.kotlin.dsl.*
30+
import org.junit.jupiter.api.io.CleanupMode
3031
import org.junit.jupiter.api.io.TempDir
3132

3233
class RebuildFilePatchesTest : TaskTest() {
@@ -39,12 +40,14 @@ class RebuildFilePatchesTest : TaskTest() {
3940
}
4041

4142
@Test
42-
fun `should rebuild patches`(@TempDir tempDir: Path) {
43+
fun `should rebuild patches`(@TempDir(cleanup = CleanupMode.ON_SUCCESS) tempDir: Path) {
44+
println("running in $tempDir")
4345
val testResource = Path.of("src/test/resources/rebuild_patches")
4446
val testInput = testResource.resolve("input")
4547

4648
val source = setupDir(tempDir, testInput, "source").toFile()
4749
setupGitRepo(source, "main", "file")
50+
setupGitHook(source)
4851
val base = setupDir(tempDir, testInput, "base").toFile()
4952
val patches = tempDir.resolve("patches").toFile()
5053
val atFile = testInput.resolve("ats.at").toFile()

0 commit comments

Comments
 (0)