From 2571fd0ce8731bed27e550ec8d361f2587ff6e27 Mon Sep 17 00:00:00 2001 From: Alex Snaps Date: Tue, 2 Aug 2022 12:03:58 -0400 Subject: [PATCH] Cleaner git_hash matching --- limitador-server/build.rs | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/limitador-server/build.rs b/limitador-server/build.rs index c2a634a7..5fb04ef5 100644 --- a/limitador-server/build.rs +++ b/limitador-server/build.rs @@ -16,16 +16,13 @@ fn main() -> Result<(), Box> { .filter(|output| output.status.success()) .map(|output| !matches!(output.stdout.len(), 0)); - if Some(true) == dirty && git_hash.is_some() { - println!( - "cargo:rustc-env=LIMITADOR_GIT_HASH={}-dirty", - git_hash.unwrap_or_else(|| "unknown".to_owned()) - ); - } else { - println!( - "cargo:rustc-env=LIMITADOR_GIT_HASH={}", - git_hash.unwrap_or_else(|| "unknown".to_owned()) - ); + match git_hash { + None => println!("cargo:rustc-env=LIMITADOR_GIT_HASH=unknown"), + Some(hash) => match dirty { + Some(true) => println!("cargo:rustc-env=LIMITADOR_GIT_HASH={}-dirty", hash), + Some(false) => println!("cargo:rustc-env=LIMITADOR_GIT_HASH={}", hash), + _ => unreachable!("How can we have a git hash, yet not know if the tree is dirty?"), + }, } if let Ok(profile) = std::env::var("PROFILE") {