aboutsummaryrefslogtreecommitdiffstats
path: root/mumctl/build.rs
diff options
context:
space:
mode:
authorEskil Queseth <eskilq@kth.se>2021-03-21 21:54:35 +0100
committerEskil Queseth <eskilq@kth.se>2021-03-21 21:54:35 +0100
commitf9d1f57e2df87ebfaecccdad230feadc1dffd609 (patch)
tree53b86c38155181b25ef1adea333a4312825f11a6 /mumctl/build.rs
parentf4f9df5ab9cc40c11164e7e696ed3a60dc7b8e34 (diff)
downloadmum-f9d1f57e2df87ebfaecccdad230feadc1dffd609.tar.gz
made more consistent output without git
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())