From 26f4321a5e9eb56b905ca9eee9cf52422c7ff859 Mon Sep 17 00:00:00 2001 From: Felix Obenhuber Date: Wed, 22 Mar 2023 09:02:16 +0100 Subject: [PATCH] Fix build if not on a git checkout (#119) Check the exit status of the `git` invocation before parsing the output. If there's no `.git` the output may look like: ``` fatal: not a git repository (or any of the parent directories): .git ``` and the version shall be set to unknown. --- cli/build.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/cli/build.rs b/cli/build.rs index afaed6578..7c1e1dc8f 100644 --- a/cli/build.rs +++ b/cli/build.rs @@ -5,6 +5,7 @@ fn main() { .args(&["rev-parse", "HEAD"]) .output() .ok() + .and_then(|output| output.status.success().then(|| output)) .and_then(|output| String::from_utf8(output.stdout[..8].into()).ok()) .unwrap_or_else(|| "(unknown version)".into()); println!("cargo:rustc-env=TYPST_VERSION={version}");