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 824065cb9c
commit 1db1d5bda7
No known key found for this signature in database
GPG Key ID: 5CAD791931B09AC4

View File

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