From 4feb21e7fc4c16255d40240457267e63a3d75a16 Mon Sep 17 00:00:00 2001 From: Kai Jan Kriegel Date: Wed, 16 Mar 2022 05:42:56 +0100 Subject: [PATCH] allow bffh to build outside of a git repo --- build.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/build.rs b/build.rs index 733c61e..02b3add 100644 --- a/build.rs +++ b/build.rs @@ -17,7 +17,10 @@ fn main() { let owned_gitrev = String::from_utf8(out.stdout) .expect("git rev-list output was not valid UTF8"); let gitrev = owned_gitrev.trim(); - let abbrev = &gitrev[0..9]; + let abbrev = match gitrev.len(){ + 0 => "unknown", + _ => &gitrev[0..9], + }; println!("cargo:rustc-env=CARGO_PKG_VERSION_GITREV={}", gitrev); let out = Command::new("git").arg("log")