From d863b54ac01cdf55a56bdfc1ea5cdab3a5805ce3 Mon Sep 17 00:00:00 2001 From: Bryan Helmkamp Date: Tue, 14 Apr 2026 20:08:45 -0400 Subject: [PATCH] fix(server): embed git SHA and build date in server binary MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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) --- .../fabro-cli/src/commands/system/info.rs | 4 --- lib/crates/fabro-server/Cargo.toml | 3 +++ lib/crates/fabro-server/build.rs | 27 +++++++++++++++++++ 3 files changed, 30 insertions(+), 4 deletions(-) create mode 100644 lib/crates/fabro-server/build.rs diff --git a/lib/crates/fabro-cli/src/commands/system/info.rs b/lib/crates/fabro-cli/src/commands/system/info.rs index c4628d542..7b42fff29 100644 --- a/lib/crates/fabro-cli/src/commands/system/info.rs +++ b/lib/crates/fabro-cli/src/commands/system/info.rs @@ -66,10 +66,6 @@ pub(super) async fn info_command( .and_then(|runs| runs.active) .unwrap_or_default() ); - println!( - "Sandbox: {}", - response.sandbox_provider.as_deref().unwrap_or("unknown") - ); println!("Uptime: {}s", response.uptime_secs.unwrap_or_default()); } diff --git a/lib/crates/fabro-server/Cargo.toml b/lib/crates/fabro-server/Cargo.toml index 3519ec272..7d2267a7c 100644 --- a/lib/crates/fabro-server/Cargo.toml +++ b/lib/crates/fabro-server/Cargo.toml @@ -79,6 +79,9 @@ walkdir.workspace = true multer = "3" thiserror.workspace = true +[build-dependencies] +chrono = { workspace = true } + [dev-dependencies] tokio = { workspace = true, features = ["test-util", "macros"] } tower = "0.5" diff --git a/lib/crates/fabro-server/build.rs b/lib/crates/fabro-server/build.rs new file mode 100644 index 000000000..c24a4d15a --- /dev/null +++ b/lib/crates/fabro-server/build.rs @@ -0,0 +1,27 @@ +#[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}"); +}