Slackbot
02/15/2024, 8:46 PMBenjamin Hoogterp
02/15/2024, 8:54 PMdef gitHashMain = new File("${rootProject.rootDir}/.git/refs/heads/main").text
Caleb Cushing
02/15/2024, 9:04 PMephemient
02/15/2024, 9:25 PMCaleb Cushing
02/15/2024, 9:26 PMephemient
02/15/2024, 9:27 PMCaleb Cushing
02/15/2024, 9:28 PMCaleb Cushing
02/15/2024, 9:28 PMAdam
02/15/2024, 9:29 PMproviders.exec { ... }
ephemient
02/15/2024, 9:29 PMval gitDescribeResult = providers.exec {
commandLine("git", "describe", "--always", "--dirty", "--long", "--tags")
isIgnoreExitValue = true
}
val version = providers.gradleProperty("version").orElse(
gitDescribeResult.result.map {
if (it.exitValue != 0) return@map "unknown-SNAPSHOT"
val describe = gitDescribeResult.standardOutput.asText.get().trim()
val match = """(.*)-((\d+)-g[0-9a-f]+)(-dirty)?""".toRegex(RegexOption.DOT_MATCHES_ALL).matchEntire(describe)
?: return@map describe.removeSuffix("-dirty").ifEmpty { "unknown" } + "-SNAPSHOT"
val (tag, extra, count, dirty) = match.destructured
when {
count.toIntOrNull() != 0 -> "$tag-$extra-SNAPSHOT"
dirty.isNotEmpty() -> "$tag-SNAPSHOT"
else -> tag
}
}
)
in one of my projects, pretty similarCaleb Cushing
02/15/2024, 9:31 PMCaleb Cushing
02/15/2024, 9:31 PMephemient
02/15/2024, 9:32 PMCaleb Cushing
02/15/2024, 9:33 PMCaleb Cushing
02/15/2024, 9:33 PMAdam
02/15/2024, 9:34 PMCaleb Cushing
02/15/2024, 9:35 PMCaleb Cushing
02/15/2024, 9:35 PMAdam
02/15/2024, 9:35 PMAdam
02/15/2024, 9:36 PMCaleb Cushing
02/15/2024, 9:37 PM./gradlew build
work againCaleb Cushing
02/15/2024, 9:37 PMAdam
02/15/2024, 9:44 PM.gradle/
dir.Caleb Cushing
02/15/2024, 9:48 PMCaleb Cushing
02/15/2024, 9:50 PMCaleb Cushing
02/15/2024, 10:38 PMCaleb Cushing
02/15/2024, 11:55 PMPorcelainGit
not because it used porcelain, but because I was creating describe
which is considered "porcelain" as a git command (I think/hope)Caleb Cushing
02/16/2024, 12:03 AMGit.class
didn't have describe
it seems to nowVampire
02/16/2024, 8:50 AMI don't remember much about that code, but it uses jgit which is pure java
is not fully correct. It does one git call to get location of system configuration file. Iirc in a static initializer, so you only hit it if you use a fresh daemon.
Caleb Cushing
02/16/2024, 1:21 PMCaleb Cushing
02/16/2024, 1:21 PM