File tree 1 file changed +20
-1
lines changed
1 file changed +20
-1
lines changed Original file line number Diff line number Diff line change @@ -72,7 +72,13 @@ allprojects {
72
72
// example: 1.0.0+fabric-1.19.2-build.100 (or -local)
73
73
val build = buildNumber?.let { " -build.${it} " } ? : " -local"
74
74
75
- version = " ${" mod_version" ()} +${project.name} -mc${" minecraft_version" () + if (isRelease) " " else build} "
75
+ var gitBranchLabel = " " ;
76
+ if (" mod_version" ().endsWith(" -alpha" )) {
77
+ // gitBranchLabel should be "-" + the current git branch (replacing any slashes with underscores)
78
+ gitBranchLabel = " -" + calculateGitBranch().replace(" /" , " _" )
79
+ }
80
+
81
+ version = " ${" mod_version" ()}${gitBranchLabel} +${project.name} -mc${" minecraft_version" () + if (isRelease) " " else build} "
76
82
77
83
tasks.withType<JavaCompile >().configureEach {
78
84
options.encoding = " UTF-8"
@@ -385,6 +391,19 @@ fun calculateGitHash(): String {
385
391
}
386
392
}
387
393
394
+ fun calculateGitBranch (): String {
395
+ try {
396
+ val stdout = ByteArrayOutputStream ()
397
+ exec {
398
+ commandLine(" git" , " rev-parse" , " --abbrev-ref" , " HEAD" )
399
+ standardOutput = stdout
400
+ }
401
+ return stdout.toString().trim()
402
+ } catch (ignored: Throwable ) {
403
+ return " unknown"
404
+ }
405
+ }
406
+
388
407
fun hasUnstaged (): Boolean {
389
408
try {
390
409
val stdout = ByteArrayOutputStream ()
You can’t perform that action at this time.
0 commit comments