From 83eeb1138891912a404e2bbf352541e3ec5e3164 Mon Sep 17 00:00:00 2001 From: Amine Date: Sun, 2 Dec 2018 13:13:19 +0100 Subject: [PATCH] Fixes #254 and #255. --- app/build.gradle | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/app/build.gradle b/app/build.gradle index b690316..aef67ef 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -2,7 +2,15 @@ buildscript { } def gitVersion() { - def process = 'git describe --contains HEAD'.execute() + def process + def maybeTagOfCurrentCommit = 'git describe --contains HEAD'.execute() + if (maybeTagOfCurrentCommit.text.isEmpty()) { + println "No tag on current commit. Will take the latest one." + process = "git for-each-ref refs/tags --sort=-authordate --format='%(refname:short)' --count=1".execute() + } else { + println "Tag found on current commit" + process = 'git describe --contains HEAD'.execute() + } return process.text.replaceAll("'", "").substring(1).replaceAll("\\.", "").trim() }