I want to get the total number of tag count in a repository
The grgit repository already solves the problem.
git = org.ajoberstar.grgit.Grgit.open()
git.tag.list().size()
But its in groovy and I want a gradle version of it.
git describe --tags $(git rev-list --tags --count)
Above code gives total number of commits
I have the following snippet so far which gets the total number of commits.
versionCode = { ->
try {
def stdout = new ByteArrayOutputStream()
exec {
commandLine 'git', 'rev-list', '--first-parent', '--count', 'HEAD'
standardOutput = stdout
}
return Integer.parseInt(stdout.toString().trim())
}
catch (ignored) {
return -1
}
}
I have referenced this SO question but without proper answer
If you don't mind using commands besides git... git tag | wc -l
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With