Skip to content

Commit

Permalink
Cleaner git_hash matching
Browse files Browse the repository at this point in the history
  • Loading branch information
alexsnaps committed Aug 2, 2022
1 parent b3509e3 commit 843bbd6
Showing 1 changed file with 7 additions and 10 deletions.
17 changes: 7 additions & 10 deletions limitador-server/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,13 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
.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") {
Expand Down

0 comments on commit 843bbd6

Please sign in to comment.