From 61a758f67d28592e412475877df191293254bf81 Mon Sep 17 00:00:00 2001 From: Thomas Lamprecht Date: Tue, 20 Jul 2021 12:29:56 +0200 Subject: [PATCH] build.rs: tell cargo to only rerun build.rs step if .git/HEAD changes Signed-off-by: Thomas Lamprecht --- build.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/build.rs b/build.rs index 037b3904..1dc1da2a 100644 --- a/build.rs +++ b/build.rs @@ -12,10 +12,12 @@ fn git_command(args: &[&str]) -> String { } fn main() { + let repo_path = git_command(&["rev-parse", "--show-toplevel"]); let repoid = match env::var("REPOID") { Ok(repoid) => repoid, Err(_) => git_command(&["rev-parse", "HEAD"]), }; println!("cargo:rustc-env=REPOID={}", repoid); + println!("cargo:rerun-if-changed={}/.git/HEAD", repo_path); }