aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--mumctl/build.rs10
-rw-r--r--mumd/build.rs10
2 files changed, 6 insertions, 14 deletions
diff --git a/mumctl/build.rs b/mumctl/build.rs
index 45cfd4e..f09b1c4 100644
--- a/mumctl/build.rs
+++ b/mumctl/build.rs
@@ -5,21 +5,17 @@ fn main() {
"{} {}-{}",
env!("CARGO_PKG_NAME"),
env!("CARGO_PKG_VERSION"),
- commit_hash(),
+ commit_hash().unwrap_or_else(|| "???".to_string()),
);
println!("cargo:rustc-env=VERSION={}", version);
}
-fn commit_hash() -> String {
+fn commit_hash() -> Option<String> {
let output = Command::new("git")
.arg("show")
.arg("--pretty=format:%h") // abbrev hash
.current_dir(env!("CARGO_MANIFEST_DIR"))
.output();
- if let Ok(output) = output {
- String::from_utf8_lossy(&output.stdout).to_string()
- } else {
- String::from("???")
- }
+ output.ok().map(|o| String::from_utf8_lossy(&o.stdout).to_string())
}
diff --git a/mumd/build.rs b/mumd/build.rs
index 45cfd4e..f09b1c4 100644
--- a/mumd/build.rs
+++ b/mumd/build.rs
@@ -5,21 +5,17 @@ fn main() {
"{} {}-{}",
env!("CARGO_PKG_NAME"),
env!("CARGO_PKG_VERSION"),
- commit_hash(),
+ commit_hash().unwrap_or_else(|| "???".to_string()),
);
println!("cargo:rustc-env=VERSION={}", version);
}
-fn commit_hash() -> String {
+fn commit_hash() -> Option<String> {
let output = Command::new("git")
.arg("show")
.arg("--pretty=format:%h") // abbrev hash
.current_dir(env!("CARGO_MANIFEST_DIR"))
.output();
- if let Ok(output) = output {
- String::from_utf8_lossy(&output.stdout).to_string()
- } else {
- String::from("???")
- }
+ output.ok().map(|o| String::from_utf8_lossy(&o.stdout).to_string())
}