From f86182e33818e1646b25f7649ec8c05aa0400266 Mon Sep 17 00:00:00 2001 From: Yihong Zhang Date: Thu, 26 Sep 2024 14:30:20 -0700 Subject: [PATCH] optional git --- build.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/build.rs b/build.rs index 7e6f35e3..1bfb473c 100644 --- a/build.rs +++ b/build.rs @@ -3,13 +3,13 @@ use std::{env, process::Command}; #[allow(clippy::disallowed_macros)] // for println! fn main() { lalrpop::process_root().unwrap(); - let output = Command::new("git") + let git_hash = Command::new("git") .args(["rev-parse", "--short", "HEAD"]) .output() - .unwrap(); - let git_hash = String::from_utf8(output.stdout).unwrap(); + .map(|output| String::from_utf8(output.stdout).unwrap_or_default()) + .unwrap_or_default(); let build_date = chrono::Utc::now().format("%Y-%m-%d"); let version = env::var("CARGO_PKG_VERSION").unwrap(); - let full_version = format!("{}_{}_{}", version, build_date, git_hash); + let full_version = format!("{}_{}{}", version, build_date, git_hash); println!("cargo:rustc-env=FULL_VERSION={}", full_version); }