fix git version extraction
This commit is contained in:
1 file changed
+19
-2
+19
-2
@@ -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());
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user