aboutsummaryrefslogtreecommitdiffstats
path: root/mumctl/build.rs
diff options
context:
space:
mode:
Diffstat (limited to 'mumctl/build.rs')
-rw-r--r--mumctl/build.rs14
1 files changed, 7 insertions, 7 deletions
diff --git a/mumctl/build.rs b/mumctl/build.rs
index 6ac9329..78f279f 100644
--- a/mumctl/build.rs
+++ b/mumctl/build.rs
@@ -1,19 +1,19 @@
use std::process::Command;
fn main() {
- let version = format!(
- "{}-{}",
- env!("CARGO_PKG_VERSION"),
- commit_hash().unwrap_or_else(|| "???".to_string()),
- );
+ let maybe_hash = commit_hash();
+ let version = match maybe_hash.as_deref() {
+ None | Some("") => format!("v{}", env!("CARGO_PKG_VERSION")),
+ Some(version) => version.to_string(),
+ };
println!("cargo:rustc-env=VERSION={}", version);
}
fn commit_hash() -> Option<String> {
let output = Command::new("git")
- .arg("show")
- .arg("--pretty=format:%h") // abbrev hash
+ .arg("describe")
+ .arg("--tags")
.current_dir(env!("CARGO_MANIFEST_DIR"))
.output();
output.ok().map(|o| String::from_utf8_lossy(&o.stdout).to_string())