Files
Android-nRF-Toolbox/gradle/git-tag-version.gradle
2022-02-16 16:34:13 +01:00

28 lines
622 B
Groovy

ext.getVersionCodeFromTags = { ->
try {
def code = new ByteArrayOutputStream()
exec {
commandLine 'git', 'log'
standardOutput = code
}
return code.toString().split("\n").size()
}
catch (ignored) {
return -1
}
}
ext.getVersionNameFromTags = { ->
try {
def stdout = new ByteArrayOutputStream()
exec {
commandLine 'git', 'describe', '--tags', '--abbrev=0'
standardOutput = stdout
}
return stdout.toString().trim().split("%")[0]
}
catch (ignored) {
return null
}
}