make git commit retrieval fail safe

This commit is contained in:
Julian Krings 2025-07-25 13:07:13 +02:00
parent 556bef6e43
commit 08b9058c8f
No known key found for this signature in database
GPG Key ID: 208C6E08C3B718D2

View File

@ -1,5 +1,6 @@
import io.github.slimjar.func.slimjar
import io.github.slimjar.resolver.data.Mirror
import org.ajoberstar.grgit.Grgit
import java.net.URI
/*
@ -140,10 +141,13 @@ tasks {
"main" to main,
"environment" to if (project.hasProperty("release")) "production" else "development",
"commit" to provider {
runCatching { grgit.head().id }
runCatching { extensions.getByType<Grgit>().head().id }
.getOrDefault("")
.takeIf { it.length == 40 } ?: "unknown"
}
.takeIf { it.length == 40 } ?: {
project.logger.error("Git commit hash not found")
"unknown"
}()
},
)
filesMatching("**/plugin.yml") {
expand(inputs.properties)