aboutsummaryrefslogtreecommitdiffstats
path: root/mumd/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 /mumd/build.rs
parentf4f9df5ab9cc40c11164e7e696ed3a60dc7b8e34 (diff)
downloadmum-f9d1f57e2df87ebfaecccdad230feadc1dffd609.tar.gz
made more consistent output without git
Diffstat (limited to 'mumd/build.rs')
-rw-r--r--mumd/build.rs15
1 files changed, 7 insertions, 8 deletions
diff --git a/mumd/build.rs b/mumd/build.rs
index f09b1c4..78f279f 100644
--- a/mumd/build.rs
+++ b/mumd/build.rs
@@ -1,20 +1,19 @@
use std::process::Command;
fn main() {
- let version = format!(
- "{} {}-{}",
- env!("CARGO_PKG_NAME"),
- 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())