Skip to content

Commit

Permalink
Fix incorrect -dirty tag on versioning
Browse files Browse the repository at this point in the history
  • Loading branch information
TBlueF committed Feb 18, 2025
1 parent 5dc74e2 commit 4c6ed2f
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions buildSrc/src/main/kotlin/versioning.kt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ fun Project.gitHash(): String {
}

fun Project.gitClean(): Boolean {
return runCommand("git status --porcelain", "NOT_CLEAN").isEmpty()
if (runCommand("git update-index --refresh", "NOT-CLEAN").equals("NOT-CLEAN")) return false;
return runCommand("git diff-index HEAD --", "NOT-CLEAN").isEmpty();
}

fun Project.gitVersion(): String {
Expand Down Expand Up @@ -37,8 +38,10 @@ private fun Project.runCommand(cmd: String, fallback: String? = null): String {
throw TimeoutException("Failed to execute command: '$cmd'")
}
.run {
val exitCode = waitFor()
if (exitCode == 0) return inputStream.bufferedReader().readText().trim()

val error = errorStream.bufferedReader().readText().trim()
if (error.isEmpty()) return inputStream.bufferedReader().readText().trim()
logger.warn("Failed to execute command '$cmd': $error")
if (fallback != null) return fallback
throw IOException(error)
Expand Down

0 comments on commit 4c6ed2f

Please sign in to comment.