Settings: 'About & updates' — check-for-updates against the forgejo repo
Bakes the source commit + build timestamp into the jar (generateBuildInfo task -> shonar-build.properties on the classpath). The Settings screen gains a 'Check for updates' button that queries the anonymous Forgejo commits API for the latest master commit and compares it to this build: up to date / update available (with commit shas and an 'Open repo' link via xdg-open) / 'newer than forgejo — local work not yet pushed' for dev builds ahead of the remote. Network failures render as a message with a repo link, never a crash. Gate: :app:compileKotlin + :app:test green (9 suites); jar property verified by unzip.
This commit is contained in:
parent
7ec6229d76
commit
7195aa1ae6
3 changed files with 155 additions and 0 deletions
|
|
@ -33,6 +33,32 @@ sourceSets {
|
|||
}
|
||||
}
|
||||
|
||||
// Bake the source commit + build time into the jar so the in-app
|
||||
// check-for-updates can tell "this build is current" from "the repo has
|
||||
// newer work". Lives on outputs so a new commit invalidates it.
|
||||
val generateBuildInfo = tasks.register("generateBuildInfo") {
|
||||
val outDir = layout.buildDirectory.dir("generated/shonar/resources")
|
||||
outputs.dir(outDir)
|
||||
val commit = providers.exec {
|
||||
commandLine("git", "-C", rootProject.projectDir.absolutePath,
|
||||
"rev-parse", "--short", "HEAD")
|
||||
}.standardOutput.asText.map { it.trim() }
|
||||
doLast {
|
||||
val dir = outDir.get().asFile
|
||||
dir.mkdirs()
|
||||
File(dir, "shonar-build.properties").writeText(
|
||||
"commit=${commit.get().ifBlank { "unknown" }}\n" +
|
||||
"builtAt=${System.currentTimeMillis()}\n",
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
sourceSets {
|
||||
main {
|
||||
resources.srcDir(generateBuildInfo)
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation(compose.desktop.currentOs)
|
||||
implementation(compose.material3)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue