aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--mumctl/build.rs14
-rw-r--r--mumd/build.rs15
-rw-r--r--mumd/src/main.rs2
3 files changed, 15 insertions, 16 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())
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())
diff --git a/mumd/src/main.rs b/mumd/src/main.rs
index e7b4bec..7c3745c 100644
--- a/mumd/src/main.rs
+++ b/mumd/src/main.rs
@@ -16,7 +16,7 @@ use tokio::task::spawn_blocking;
#[tokio::main]
async fn main() {
if std::env::args().find(|s| s.as_str() == "--version").is_some() {
- println!(env!("VERSION"));
+ println!("mumd {}", env!("VERSION"));
return;
}