9
0
mirror of https://github.com/HibiscusMC/HMCCosmetics.git synced 2025-12-19 15:09:19 +00:00

chore: improve version handling

This commit is contained in:
LoJoSho
2024-12-28 18:20:09 -06:00
parent e4c4933d46
commit c7667b2dc2

View File

@@ -8,7 +8,7 @@ plugins {
} }
group = "com.hibiscusmc" group = "com.hibiscusmc"
version = "2.7.4-DEV-${getGitCommitHash()}" version = "2.7.4${getGitCommitHash()}"
allprojects { allprojects {
apply(plugin = "java") apply(plugin = "java")
@@ -265,13 +265,21 @@ java {
} }
fun getGitCommitHash(): String { fun getGitCommitHash(): String {
return try { var includeHash = true;
val process = ProcessBuilder("git", "rev-parse", "--short", "HEAD") val includeHashVariable = System.getenv("HMCC_INCLUDE_HASH")
.redirectErrorStream(true)
.start()
process.inputStream.bufferedReader().use { it.readLine().trim() } if (!includeHashVariable.isNullOrEmpty()) includeHash = includeHashVariable.toBoolean()
} catch (e: Exception) {
"unknown" // Fallback if Git is not available or an error occurs if (includeHash) {
return try {
val process = ProcessBuilder("git", "rev-parse", "--short", "HEAD")
.redirectErrorStream(true)
.start()
process.inputStream.bufferedReader().use { "-" + it.readLine().trim() }
} catch (e: Exception) {
"-unknown" // Fallback if Git is not available or an error occurs
}
} }
return ""
} }