From bef2f861381cbdd997f8462ced3af98e3cba3ce0 Mon Sep 17 00:00:00 2001 From: Moritz Zwerger Date: Tue, 6 Feb 2024 07:49:49 +0100 Subject: [PATCH] build: always print unclean status when initializing git --- .gitlab-ci.yml | 1 + build.gradle.kts | 14 ++++++++------ 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 291d25bbcf..4789ee340e 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -63,6 +63,7 @@ test: reports: junit: build/test-results/**/TEST-*.xml +# TODO: upload release in the publish step? package: stage: package script: diff --git a/build.gradle.kts b/build.gradle.kts index ff23fe69b2..0c169c68dc 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -431,6 +431,9 @@ tasks.test { var git: Grgit? = null var commit: Commit? = null + +fun Commit.shortId() = id.substring(0, 10) + fun loadGit() { val git: Grgit try { @@ -447,10 +450,12 @@ fun loadGit() { stable = true tag.name } else { - commit.id.substring(0, 10) + commit.shortId() } - if (!git.status().isClean) { + val status = git.status() + if (!status.isClean) { nextVersion += "-dirty" + println(status) } if (project.version != nextVersion) { project.version = nextVersion @@ -466,13 +471,10 @@ val versionJsonTask = tasks.register("versionJson") { doFirst { fun generateGit(git: Grgit, commit: Commit): Map { val status = git.status() - if (!status.isClean) { - println(status) - } return mapOf( "branch" to (System.getenv()["CI_COMMIT_BRANCH"] ?: git.branch.current().name), "commit" to commit.id, - "commit_short" to commit.abbreviatedId, + "commit_short" to commit.shortId(), "dirty" to !status.isClean, ) }