From 01a6d9704623099127e81ba1347b5347b6c1797b Mon Sep 17 00:00:00 2001 From: Bixilon Date: Sat, 22 Oct 2022 19:26:35 +0200 Subject: [PATCH] gradle: append `-dirty` to version if git status is not clean --- build.gradle.kts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/build.gradle.kts b/build.gradle.kts index 4f170a41c..77f4039c8 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -371,12 +371,15 @@ fun loadGit() { git = Grgit.open(mapOf("currentDir" to project.rootDir)) val commit = git.log().first() val tag = git.tag.list().find { it.commit == commit } - val nextVersion = if (tag != null) { + var nextVersion = if (tag != null) { stable = true tag.name } else { commit.abbreviatedId } + if (!git.status().isClean) { + nextVersion += "-dirty" + } if (project.version != nextVersion) { project.version = nextVersion println("Version changed to ${project.version}")