Skip to content

Commit

Permalink
chore: improve version handling
Browse files Browse the repository at this point in the history
  • Loading branch information
LoJoSho committed Dec 29, 2024
1 parent e4c4933 commit c7667b2
Showing 1 changed file with 17 additions and 9 deletions.
26 changes: 17 additions & 9 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ plugins {
}

group = "com.hibiscusmc"
version = "2.7.4-DEV-${getGitCommitHash()}"
version = "2.7.4${getGitCommitHash()}"

allprojects {
apply(plugin = "java")
Expand Down Expand Up @@ -265,13 +265,21 @@ java {
}

fun getGitCommitHash(): String {
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
var includeHash = true;
val includeHashVariable = System.getenv("HMCC_INCLUDE_HASH")

if (!includeHashVariable.isNullOrEmpty()) includeHash = includeHashVariable.toBoolean()

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 ""
}

0 comments on commit c7667b2

Please sign in to comment.