From 1fc41d61c8e78d4c139f177b977902eb06694e1f Mon Sep 17 00:00:00 2001 From: Krzysztof Romanwoski Date: Fri, 11 Sep 2020 12:44:26 +0200 Subject: [PATCH] Fix up versioning --- build.gradle.kts | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index 1383ef9..2cd62a4 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -27,11 +27,16 @@ fun String.run(): String? { } } +val ciGeneratedFiles = listOf("settings.xml") + fun getVersion(): String { val base = "git describe --tags --exact-match".run() ?: "git describe --tags".run() ?: "0.1.0-SNAPSHOT" - val statusStr = "git status --porcelain".run()?.let { if (it.trim().length > 2) "-SNAPSHOT" else "" } ?: "-SNAPSHOT" - val v = base + statusStr + val changedFiles = "git status --porcelain".run()?.lines() + ?.filterNot { line -> line.isEmpty() || ciGeneratedFiles.find { file -> line.endsWith(" $file") } != null } + + val statusStr = changedFiles?.let { if (it.isEmpty()) "" else "-SNAPSHOT" } ?: "-SNAPSHOT" + val v = base.removePrefix("v") + statusStr println("Using $v version.") return v }