diff options
| author | Gustav Sörnäs <gustav@sornas.net> | 2021-03-21 14:59:03 +0100 |
|---|---|---|
| committer | Gustav Sörnäs <gustav@sornas.net> | 2021-03-21 14:59:03 +0100 |
| commit | abbea6a4a20ed1562d99ce5942154352bc545eb5 (patch) | |
| tree | dc3ec66a37a5450551a6535f53da6227fa94f06a /mumd/build.rs | |
| parent | 6aa40e1e96a6c3f0aabdf438f5d260edfa559b30 (diff) | |
| download | mum-abbea6a4a20ed1562d99ce5942154352bc545eb5.tar.gz | |
commit_hash returns option instead
Diffstat (limited to 'mumd/build.rs')
| -rw-r--r-- | mumd/build.rs | 10 |
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()) } |
