From 64e54d89eb76eb2f319deb0e39c0b4f764d60996 Mon Sep 17 00:00:00 2001 From: Luck Date: Sun, 23 Sep 2018 15:20:22 +0100 Subject: [PATCH] Refactor buildscript determinePatchVersion function --- build.gradle | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/build.gradle b/build.gradle index 772c1de1..af7c7df6 100644 --- a/build.gradle +++ b/build.gradle @@ -18,21 +18,17 @@ subprojects { def determinePatchVersion = { // get the name of the last tag - def lastTag = new ByteArrayOutputStream() + def tagInfo = new ByteArrayOutputStream() exec { - commandLine 'git', 'describe', '--tags', '--abbrev=0', '@^' - standardOutput = lastTag + commandLine 'git', 'describe', '--tags' + standardOutput = tagInfo } + tagInfo = tagInfo.toString() - // get a list of the commits since the last tag - def commitsSinceLastTag = new ByteArrayOutputStream() - exec { - commandLine 'git', 'log', '--oneline', lastTag.toString().trim() + '..@' - standardOutput = commitsSinceLastTag + if (!tagInfo.contains('-')) { + return 0 } - - // calculate what the patch version should be - return Integer.toString(commitsSinceLastTag.toString().split("\n").length) + return tagInfo.split("-")[1] } project.ext.majorVersion = '4'