fix git version extraction

This commit is contained in:
ktims committed 2026-11-11 18:16:51 -07:00
1 parent 44679cda2c
commit 27c8fa6a32
1 file changed
+19 -2
+19 -2
View File
@@ -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<String> { fn git_output(args: &[&str], dir: &str) -> Option<String> {
let output = Command::new("git") let output = Command::new("git")
@@ -28,6 +38,13 @@ fn main() {
"cargo:rustc-env=GUAC_VERSION={}", "cargo:rustc-env=GUAC_VERSION={}",
firmware_version(&manifest_dir) 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());
}
}
} }
} }