Skip to content
Snippets Groups Projects
Commit f45ce136 authored by Matyáš Latner's avatar Matyáš Latner
Browse files

New gradle versioning pattern

parent 6f4292c6
Branches
Tags
No related merge requests found
......@@ -193,11 +193,40 @@ task processAssets(dependsOn: [':util:checksum:runChecksum', ':util:checksum:run
def getVersionNameFromGit() {
def stdout = new ByteArrayOutputStream()
String branchName = getBrancheNameFromGit()
// get last tag in current branch
exec {
commandLine 'git', 'describe', '--tags', '--always'
commandLine 'git', 'describe', '--abbrev=0', '--tags', '--first-parent'
standardOutput = stdout
}
return stdout.toString().trim()
String result = stdout.toString().trim();
// for non release branches add number of commits and branch name
if (!"master".equals(branchName)) {
stdout = new ByteArrayOutputStream()
exec {
commandLine 'git', 'rev-list', '--tags', '--no-walk', '--max-count=1', '--first-parent'
standardOutput = stdout
}
String revision = stdout.toString().trim()
stdout = new ByteArrayOutputStream()
exec {
commandLine 'git', 'rev-list', "${revision}..HEAD", '--count', '--first-parent'
standardOutput = stdout
}
String numberOfCommits = stdout.toString().trim()
if ("devel".equals(branchName)) {
// add only number of commits for devel branch
result = "${result}-${numberOfCommits}"
} else {
// add branch name and number of commits
result = "${result}-${branchName}-${numberOfCommits}"
}
}
return result
}
def getVersionCodeFromGit() {
......@@ -209,6 +238,15 @@ def getVersionCodeFromGit() {
return stdout.toString().trim().toInteger()
}
def getBrancheNameFromGit() {
def stdout = new ByteArrayOutputStream()
exec {
commandLine 'git', 'rev-parse', '--abbrev-ref', 'HEAD'
standardOutput = stdout
}
return stdout.toString().trim().toLowerCase()
}
def getMapConvertedToString(Map map) {
String result = "";
map.each { key, value ->
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment