diff --git a/doc/build.rs b/doc/build.rs index 4dd59fd0b0..29f1b44a07 100644 --- a/doc/build.rs +++ b/doc/build.rs @@ -1,4 +1,5 @@ use std::env; +use std::path::Path; use std::process::Command; fn main() { @@ -10,6 +11,9 @@ fn main() { let git_hash = String::from_utf8(output.stdout).unwrap(); println!("cargo:rustc-env=GIT_HASH={}", git_hash); } - // This is the closest thing to making sure we rebuild this every time a new commit is made - println!("cargo:rerun-if-changed=../.git/COMMIT_EDITMSG"); + let git_edit_msg = "../.git/COMMIT_EDITMSG"; + if Path::new(git_edit_msg).exists() { + // This is the closest thing to making sure we rebuild this every time a new commit is made + println!("cargo:rerun-if-changed={}", git_edit_msg); + } }