From e5b937b995f9ef508c64d10d5fd2a2c5af7cb25d Mon Sep 17 00:00:00 2001 From: sspanak Date: Mon, 15 Aug 2022 09:48:51 +0300 Subject: [PATCH] fixed the user version being incorrectly incremented more than it should --- build.gradle | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/build.gradle b/build.gradle index d82327c6..fe10aada 100644 --- a/build.gradle +++ b/build.gradle @@ -44,9 +44,12 @@ def computeVersionCode = { -> } def computeVersionName = { -> - String tagsCount = execThing('git tag').split('\n').size() + 1 // initially, versions were 1-based + String tagsCount = execThing('git tag').split('\n').size() String lastTag = execThing('git describe --tags --abbrev=0') - String commitsSinceLastTag = execThing("git log $lastTag..HEAD --oneline").split('\n').size() + 1 + + String gitLogResult = execThing("git log $lastTag..HEAD --oneline") + String commitsSinceLastTag = gitLogResult.equals('') ? "0" : gitLogResult.split('\n').size(); + String currentHash = execThing('git log -1 --format=%h') return "$tagsCount.$commitsSinceLastTag ($currentHash)"