From d80dbd52c45b30d604955b07cb9f57a3840230e2 Mon Sep 17 00:00:00 2001 From: Michael-F-Bryan Date: Thu, 28 Jul 2022 10:01:05 +0800 Subject: [PATCH] Explicitly run "git describe" in the crate directory --- crates/fj-app/build.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/crates/fj-app/build.rs b/crates/fj-app/build.rs index 4ed16d62b..78ecdc31c 100644 --- a/crates/fj-app/build.rs +++ b/crates/fj-app/build.rs @@ -32,10 +32,13 @@ fn version_string() -> String { /// we're building just the `fj-app` crate in a Docker container or when /// someone is installing from crates.io via `cargo install`. fn git_description() -> Option { + let crate_dir = PathBuf::from(std::env::var("CARGO_MANIFEST_DIR").unwrap()); + let mut cmd = Command::new("git"); cmd.args(["describe", "--always", "--dirty=-modified"]) .stdout(Stdio::piped()) - .stderr(Stdio::piped()); + .stderr(Stdio::piped()) + .current_dir(&crate_dir); let Output { status, @@ -58,7 +61,6 @@ fn git_description() -> Option { } // Make sure we re-run whenever the current commit changes - let crate_dir = PathBuf::from(std::env::var("CARGO_MANIFEST_DIR").unwrap()); let project_root = crate_dir.ancestors().nth(2).unwrap(); let head_file = project_root.join(".git").join("HEAD"); println!("cargo:rerun-if-changed={}", head_file.display());