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: <hash>. No more
guessing whether the rebuild actually deployed.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
dave
2026-04-11 20:50:15 +00:00
parent e32300d1f8
commit 8393a67c89
2 changed files with 17 additions and 1 deletions
+5
View File
@@ -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 app_state = Arc::new(SessionState::default());
let cwd = std::env::current_dir().unwrap_or_else(|_| PathBuf::from(".")); let cwd = std::env::current_dir().unwrap_or_else(|_| PathBuf::from("."));
// Migrate legacy root-level store.json into .huskies/ if the new path does // Migrate legacy root-level store.json into .huskies/ if the new path does
+12 -1
View File
@@ -175,7 +175,18 @@ pub async fn rebuild_and_restart(
return Err(format!("Build failed:\n{stderr}")); 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 // 5. Send shutdown notification before replacing the process so that chat
// participants know the bot is going offline. Best-effort only — we // participants know the bot is going offline. Best-effort only — we