gradle: append -dirty to version if git status is not clean

This commit is contained in:
Bixilon 2022-10-22 19:26:35 +02:00
parent b7a84f9dfa
commit 01a6d97046
No known key found for this signature in database
GPG Key ID: 5CAD791931B09AC4

View File

@ -371,12 +371,15 @@ fun loadGit() {
git = Grgit.open(mapOf("currentDir" to project.rootDir))
val commit = git.log().first()
val tag = git.tag.list().find { it.commit == commit }
val nextVersion = if (tag != null) {
var nextVersion = if (tag != null) {
stable = true
tag.name
} else {
commit.abbreviatedId
}
if (!git.status().isClean) {
nextVersion += "-dirty"
}
if (project.version != nextVersion) {
project.version = nextVersion
println("Version changed to ${project.version}")