aboutsummaryrefslogtreecommitdiffstats
path: root/mumd/build.rs
diff options
context:
space:
mode:
authorGustav Sörnäs <gustav@sornas.net>2021-03-21 14:59:03 +0100
committerGustav Sörnäs <gustav@sornas.net>2021-03-21 14:59:03 +0100
commitabbea6a4a20ed1562d99ce5942154352bc545eb5 (patch)
treedc3ec66a37a5450551a6535f53da6227fa94f06a /mumd/build.rs
parent6aa40e1e96a6c3f0aabdf438f5d260edfa559b30 (diff)
downloadmum-abbea6a4a20ed1562d99ce5942154352bc545eb5.tar.gz
commit_hash returns option instead
Diffstat (limited to 'mumd/build.rs')
-rw-r--r--mumd/build.rs10
1 files changed, 3 insertions, 7 deletions
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())
}