From 8393a67c89bc65e8f1e59be08cda293f39e2b244 Mon Sep 17 00:00:00 2001 From: dave Date: Sat, 11 Apr 2026 20:50:15 +0000 Subject: [PATCH] fix: log git hash on build success and startup to verify which commit is running Writes HEAD short hash to .huskies/build_hash after successful cargo build. Logs it on startup as [startup] Running build: . No more guessing whether the rebuild actually deployed. Co-Authored-By: Claude Opus 4.6 (1M context) --- server/src/main.rs | 5 +++++ server/src/rebuild.rs | 13 ++++++++++++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/server/src/main.rs b/server/src/main.rs index 9c02d514..7c75ab47 100644 --- a/server/src/main.rs +++ b/server/src/main.rs @@ -171,6 +171,11 @@ async fn main() -> Result<(), std::io::Error> { } }); + // Log the build hash so we can verify which commit is running. + let build_hash = std::fs::read_to_string(".huskies/build_hash") + .unwrap_or_else(|_| "unknown".to_string()); + slog!("[startup] Running build: {}", build_hash.trim()); + let app_state = Arc::new(SessionState::default()); let cwd = std::env::current_dir().unwrap_or_else(|_| PathBuf::from(".")); // Migrate legacy root-level store.json into .huskies/ if the new path does diff --git a/server/src/rebuild.rs b/server/src/rebuild.rs index 9ab8074d..b4f5af0e 100644 --- a/server/src/rebuild.rs +++ b/server/src/rebuild.rs @@ -175,7 +175,18 @@ pub async fn rebuild_and_restart( return Err(format!("Build failed:\n{stderr}")); } - slog!("[rebuild] Build succeeded, re-execing with new binary"); + // Write the current git HEAD to a file so we can verify which commit is running. + if let Ok(head) = std::process::Command::new("git") + .args(["rev-parse", "--short", "HEAD"]) + .current_dir(workspace_root) + .output() + { + let hash = String::from_utf8_lossy(&head.stdout).trim().to_string(); + let _ = std::fs::write(workspace_root.join(".huskies/build_hash"), &hash); + slog!("[rebuild] Build succeeded (commit {hash}), re-execing with new binary"); + } else { + slog!("[rebuild] Build succeeded, re-execing with new binary"); + } // 5. Send shutdown notification before replacing the process so that chat // participants know the bot is going offline. Best-effort only — we