mirror of
https://github.com/HibiscusMC/HibiscusCommons.git
synced 2025-12-19 15:09:26 +00:00
feat: testing git commit in version
This commit is contained in:
@@ -11,7 +11,7 @@ plugins {
|
||||
}
|
||||
|
||||
group = "me.lojosho"
|
||||
version = "0.5.1"
|
||||
version = "0.5.2-${getGitCommitHash()}"
|
||||
|
||||
allprojects {
|
||||
apply(plugin = "java")
|
||||
@@ -305,3 +305,15 @@ class PublishData(private val project: Project) {
|
||||
name.plus(append).plus(if (appendCommit && addCommit) "-".plus(commitHash) else "")
|
||||
}
|
||||
}
|
||||
|
||||
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
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user