From 27c8fa6a32ff0e6fbb529ed757ee8167e085d2ae Mon Sep 17 00:00:00 2001 From: Keenan Tims Date: Wed, 11 Nov 2026 18:16:51 -0700 Subject: [PATCH] fix git version extraction --- firmware/build.rs | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/firmware/build.rs b/firmware/build.rs index fb286be..84d0f5a 100644 --- a/firmware/build.rs +++ b/firmware/build.rs @@ -1,4 +1,14 @@ -use std::{env, process::Command}; +use std::{env, path::Path, process::Command}; + +/// Paths that change when `HEAD`, a branch, or a tag moves. `HEAD` itself is only rewritten on +/// checkout, so commits are tracked through the reflog and the ref directories. +const GIT_WATCH: [&str; 5] = [ + "../.git/HEAD", + "../.git/logs/HEAD", + "../.git/refs/heads", + "../.git/refs/tags", + "../.git/packed-refs", +]; fn git_output(args: &[&str], dir: &str) -> Option { let output = Command::new("git") @@ -28,6 +38,13 @@ fn main() { "cargo:rustc-env=GUAC_VERSION={}", firmware_version(&manifest_dir) ); - println!("cargo:rerun-if-changed=../.git/HEAD"); + + for path in GIT_WATCH { + let path = Path::new(&manifest_dir).join(path); + + if path.exists() { + println!("cargo:rerun-if-changed={}", path.display()); + } + } } }