Skip to content

Commit

Permalink
Tweak git version logic
Browse files Browse the repository at this point in the history
  • Loading branch information
avsaase committed Mar 15, 2023
1 parent 97c9d42 commit ccdd8c6
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions src/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)),
}
}

Expand Down

0 comments on commit ccdd8c6

Please sign in to comment.