mirror of
https://github.com/fabro-sh/fabro.git
synced 2026-10-06 02:48:25 +00:00
The server used option_env!() for FABRO_GIT_SHA and FABRO_BUILD_DATE, but no build.rs set them — so `fabro version` always showed "unknown". Add a build.rs to fabro-server (matching fabro-cli's) and remove the Sandbox line from `fabro system info`. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
27 lines
889 B
Rust
27 lines
889 B
Rust
#[expect(
|
|
clippy::disallowed_methods,
|
|
reason = "Build scripts run outside Tokio and need a synchronous git probe for the embedded build SHA."
|
|
)]
|
|
fn main() {
|
|
println!("cargo:rerun-if-changed=../../../.git/HEAD");
|
|
|
|
let sha = std::process::Command::new("git")
|
|
.args(["rev-list", "-1", "HEAD"])
|
|
.output()
|
|
.ok()
|
|
.and_then(|o| {
|
|
if o.status.success() {
|
|
String::from_utf8(o.stdout)
|
|
.ok()
|
|
.map(|s| s.trim().to_string())
|
|
} else {
|
|
None
|
|
}
|
|
})
|
|
.unwrap_or_default();
|
|
let short_sha = if sha.len() >= 7 { &sha[..7] } else { &sha };
|
|
println!("cargo:rustc-env=FABRO_GIT_SHA={short_sha}");
|
|
|
|
let build_date = chrono::Utc::now().format("%Y-%m-%d").to_string();
|
|
println!("cargo:rustc-env=FABRO_BUILD_DATE={build_date}");
|
|
}
|