|
1 | 1 | import me.modmuss50.mpp.ReleaseType |
2 | 2 |
|
| 3 | +String runGitCommand(Project project, List<String> args) { |
| 4 | + try { |
| 5 | + def output = new ByteArrayOutputStream() |
| 6 | + project.exec { |
| 7 | + commandLine(["git"] + args) |
| 8 | + standardOutput = output |
| 9 | + ignoreExitValue = true |
| 10 | + } |
| 11 | + |
| 12 | + def result = output.toString("UTF-8").trim() |
| 13 | + return result ? result : "unknown" |
| 14 | + } catch (Exception ignored) { |
| 15 | + return "unknown" |
| 16 | + } |
| 17 | +} |
| 18 | + |
| 19 | +String latestCommitHash(Project project) { |
| 20 | + return runGitCommand(project, ["rev-parse", "--short", "HEAD"]) |
| 21 | +} |
| 22 | + |
| 23 | +String latestCommitMessage(Project project) { |
| 24 | + return runGitCommand(project, ["log", "-1", "--pretty=%B"]) |
| 25 | +} |
| 26 | + |
3 | 27 | buildscript { |
4 | 28 | // Unify build logic of all submodules in here, ugly but easier since we have to deal with a lot random stuff |
5 | 29 | repositories { |
@@ -262,7 +286,13 @@ subprojects { |
262 | 286 | } else { |
263 | 287 | file = tasks.shadowJar.archiveFile |
264 | 288 | } |
265 | | - changelog = "A changelog can be found at https://github.com/ViaVersion/ViaForge/commits" |
| 289 | + def commitHash = latestCommitHash(rootProject) |
| 290 | + def commitMessage = latestCommitMessage(rootProject).replaceAll("\\s+", " ").trim() |
| 291 | + if (commitHash == "unknown" || commitMessage == "unknown") { |
| 292 | + changelog = "A changelog can be found at https://github.com/ViaVersion/ViaForge/commits" |
| 293 | + } else { |
| 294 | + changelog = "[${commitHash}](https://github.com/ViaVersion/ViaForge/commit/${commitHash}) ${commitMessage}" |
| 295 | + } |
266 | 296 | version = project.version.toString() + "+" + mcVersion |
267 | 297 | displayName = version |
268 | 298 | modLoaders.add("forge") |
|
0 commit comments