Skip to content

Commit

Permalink
Simplify getGitVersion() in build.gradle.kts
Browse files Browse the repository at this point in the history
  • Loading branch information
markwhitaker committed Oct 3, 2024
1 parent eb34619 commit 7a6c339
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,11 @@ dependencies {
testImplementation("junit:junit:$junitVersion")
}

fun getGitVersion(): String {
try {
val process = ProcessBuilder("git", "describe", "--tags", "--always").start()
val output = process.inputStream.bufferedReader().readLine()
process.waitFor()
return output
} catch (e: Exception) {
return "1.0.0"
}
fun getGitVersion() = try {
val process = ProcessBuilder("git", "describe", "--tags", "--always").start()
val output = process.inputStream.bufferedReader().readLine()
process.waitFor()
output
} catch (_: Exception) {
"1.0.0"
}

0 comments on commit 7a6c339

Please sign in to comment.