From 9b02b4886a15e1f8cdded17d4a05626866d31381 Mon Sep 17 00:00:00 2001 From: Sylvain Berfini Date: Mon, 14 Oct 2019 11:22:44 +0200 Subject: [PATCH] Updated build.gradle to use new semantic versioning --- app/build.gradle | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index 3ad8a7cee..c70c24e3a 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -24,15 +24,26 @@ static def isLocalAarAvailable() { } task getGitVersion() { - def gitVersion = "4.1" + def gitVersion = "4.2" def gitVersionStream = new ByteArrayOutputStream() + def gitCommitsCount = new ByteArrayOutputStream() + def gitCommitHash = new ByteArrayOutputStream() try { exec { - executable "git" args "describe", "--always" + executable "git" args "describe", "--abbrev=0" standardOutput = gitVersionStream } - gitVersion = gitVersionStream.toString().trim() + exec { + executable "git" args "rev-list", gitVersionStream.toString().trim() + "..HEAD", "--count" + standardOutput = gitCommitsCount + } + exec { + executable "git" args "rev-parse", "--short", "HEAD" + standardOutput = gitCommitHash + } + + gitVersion = gitVersionStream.toString().trim() + "." + gitCommitsCount.toString().trim() + "+" + gitCommitHash.toString().trim() println("Git version: " + gitVersion) } catch (Exception e) { println("Git not found")