Add dirty if there is uncommitted changes

This commit is contained in:
frknkrc44 2025-08-11 16:00:02 +03:00
commit 5df8a94e35
No known key found for this signature in database
GPG key ID: 784AE1CC0DCFD34F

View file

@ -10,15 +10,23 @@ plugins {
}
fun String.execute(currentWorkingDir: File = file("./")): String {
val byteOut = java.io.ByteArrayOutputStream()
project.exec {
val out = providers.exec {
workingDir = currentWorkingDir
commandLine = split("\\s".toRegex())
standardOutput = byteOut
}
return String(byteOut.toByteArray()).trim()
return out.standardOutput.asText.get().trim()
}
fun getUncommittedSuffix(): String {
val result = "git status -suno".execute()
if (result.isEmpty()) {
return ""
}
return "-dirty+${result.count { it == '\n' } + 1}"
}
val gitHasUncommittedSuffix = getUncommittedSuffix()
val gitCommitCount = "git rev-list HEAD --count".execute().toInt()
val gitCommitHash = "git rev-parse --verify --short HEAD".execute()
val gitCommitCountAfterOss = gitCommitCount - 432
@ -27,7 +35,7 @@ val minSdkVer by extra(28)
val targetSdkVer by extra(36)
val appVerCode = gitCommitCount + 0x6f7373
val appVerName by extra("3.3.1-oss-${gitCommitCountAfterOss}")
val appVerName by extra("3.3.1-oss-${gitCommitCountAfterOss}${gitHasUncommittedSuffix}")
val configVerCode by extra(90)
val serviceVerCode by extra(97)
val minBackupVerCode by extra(65)