From b8a6e82faae6fa31cd2b058c1dfd99cba71d23d9 Mon Sep 17 00:00:00 2001 From: Jeremy Kong Date: Thu, 1 Apr 2021 11:13:40 +0100 Subject: [PATCH] Sanitizing the Git Version for Correct Snapshot Publishing (#5357) * circleci update * corner cases: * test * hack * hack * fix extra line * don't need that * this way is safer * fix --- build.gradle | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index 278d4c5afcc..66f2fdb5fbb 100644 --- a/build.gradle +++ b/build.gradle @@ -39,9 +39,19 @@ apply plugin: 'com.palantir.external-publish' apply from: 'gradle/versions.gradle' group = 'com.palantir.atlasdb' -version = gitVersion() +version = sanitizeVersion() description = 'Transactional distributed database layer' +def sanitizeVersion() { + def isClean = "git status --porcelain".execute().text.isEmpty() + def pluginReportedVersion = gitVersion() + + if (isClean && pluginReportedVersion.endsWith(".dirty")) { + return pluginReportedVersion.dropRight(".dirty".length()) + } + return pluginReportedVersion +} + task printLastVersion { doLast { def details = versionDetails()