From ccdd8c6294bf2db7b92a8830611af36b71b50b66 Mon Sep 17 00:00:00 2001 From: Alexander van Saase Date: Wed, 15 Mar 2023 08:48:11 +0100 Subject: [PATCH] Tweak git version logic --- src/util.rs | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/util.rs b/src/util.rs index 543dd30..c9eef89 100644 --- a/src/util.rs +++ b/src/util.rs @@ -83,14 +83,13 @@ pub mod build_info { let version: Option<&'static str> = option_env!("GIT_VERSION"); let short_hash: Option<&'static str> = option_env!("GIT_COMMIT_HASH"); let dirty: bool = option_env!("GIT_DIRTY").map(|s| s == "1").unwrap_or(false); + let dirty_or_empty = if dirty { "-dirty" } else { "" }; match (version, short_hash) { (None, None) => None, - (None, Some(commit)) if dirty => Some(format!("unreleased ({}-dirty)", commit)), - (None, Some(commit)) => Some(format!("dev ({})", commit)), + (None, Some(commit)) => Some(format!("dev ({}{})", commit, dirty_or_empty)), (Some(version), None) => Some(version.to_string()), - (Some(version), Some(commit)) if dirty => Some(format!("{} ({}-dirty)", version, commit)), - (Some(version), Some(commit)) => Some(format!("{} ({})", version, commit)), + (Some(version), Some(commit)) => Some(format!("{} ({}{})", version, commit, dirty_or_empty)), } }