Skip to content

Commit 4c6ed2f

Browse files
committed
Fix incorrect -dirty tag on versioning
1 parent 5dc74e2 commit 4c6ed2f

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

Diff for: buildSrc/src/main/kotlin/versioning.kt

+5-2
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ fun Project.gitHash(): String {
88
}
99

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

1415
fun Project.gitVersion(): String {
@@ -37,8 +38,10 @@ private fun Project.runCommand(cmd: String, fallback: String? = null): String {
3738
throw TimeoutException("Failed to execute command: '$cmd'")
3839
}
3940
.run {
41+
val exitCode = waitFor()
42+
if (exitCode == 0) return inputStream.bufferedReader().readText().trim()
43+
4044
val error = errorStream.bufferedReader().readText().trim()
41-
if (error.isEmpty()) return inputStream.bufferedReader().readText().trim()
4245
logger.warn("Failed to execute command '$cmd': $error")
4346
if (fallback != null) return fallback
4447
throw IOException(error)

0 commit comments

Comments
 (0)