mirror of
https://github.com/PurpurMC/Purpur.git
synced 2026-02-19 01:17:42 +01:00
Build using Toothpick scripts (#122)
Co-authored-by: BillyGalbreath <blake.galbreath@gmail.com>
This commit is contained in:
33
buildSrc/src/main/kotlin/task/UpstreamCommit.kt
Normal file
33
buildSrc/src/main/kotlin/task/UpstreamCommit.kt
Normal file
@@ -0,0 +1,33 @@
|
||||
package task
|
||||
|
||||
import ensureSuccess
|
||||
import gitCmd
|
||||
import org.gradle.api.Project
|
||||
import org.gradle.api.Task
|
||||
import taskGroup
|
||||
import toothpick
|
||||
import upstreamDir
|
||||
|
||||
internal fun Project.createUpstreamCommitTask(
|
||||
receiver: Task.() -> Unit = {}
|
||||
): Task = tasks.create("upstreamCommit") {
|
||||
receiver(this)
|
||||
group = taskGroup
|
||||
doLast {
|
||||
val oldRev = ensureSuccess(gitCmd("ls-tree", "HEAD", toothpick.upstream))
|
||||
?.substringAfter("commit ")?.substringBefore("\t")
|
||||
val gitChangelog =
|
||||
ensureSuccess(gitCmd("log", "--oneline", "$oldRev...HEAD", printOut = true, dir = upstreamDir)) {
|
||||
logger.lifecycle("No upstream changes to commit?")
|
||||
}
|
||||
val commitMessage = """
|
||||
|Updated Upstream (${toothpick.upstream})
|
||||
|
|
||||
|Upstream has released updates that appear to apply and compile correctly
|
||||
|
|
||||
|${toothpick.upstream} Changes:
|
||||
|$gitChangelog
|
||||
""".trimMargin()
|
||||
ensureSuccess(gitCmd("commit", "-m", commitMessage, printOut = true))
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user