From 34d7b5d9deb93ee1c40f080166ce674c19560a2f Mon Sep 17 00:00:00 2001 From: steven-omaha <35634100+steven-omaha@users.noreply.github.com> Date: Mon, 15 May 2023 15:58:57 +0200 Subject: [PATCH] fix: build when git not installed When the git binary is not available, emit an empty git_hash so that the build continues instead of aborting due to an unset environment variable --- crates/pacdef_core/build.rs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/crates/pacdef_core/build.rs b/crates/pacdef_core/build.rs index 33069fc..b8d6986 100644 --- a/crates/pacdef_core/build.rs +++ b/crates/pacdef_core/build.rs @@ -1,10 +1,13 @@ use std::process::Command; fn main() { - let output = Command::new("git") + let git_hash = match Command::new("git") .args(["rev-parse", "--short", "HEAD"]) .output() - .unwrap(); - let git_hash = String::from_utf8(output.stdout).unwrap(); + { + Ok(output) => String::from_utf8(output.stdout).expect("git output is utf-8"), + _ => String::new(), + }; + println!("cargo:rustc-env=GIT_HASH={git_hash}"); }