diff options
author | Andrew Gallant <jamslam@gmail.com> | 2018-02-20 19:46:47 -0500 |
---|---|---|
committer | Andrew Gallant <jamslam@gmail.com> | 2018-02-20 20:05:55 -0500 |
commit | fe9be658f410d2e35c1cfe236a338f95aa03a724 (patch) | |
tree | 5b4215c2b532094bab8eacc8387cc5d49932a12b /build.rs | |
parent | 8c800adab7ca441519e4bc503450123a80923c41 (diff) |
doc: omit revision when it isn't available
If the revision is empty, then we shouldn't show the `(rev )` text in
the output of `rg --version`.
Fixes #789
Diffstat (limited to 'build.rs')
-rw-r--r-- | build.rs | 9 |
1 files changed, 7 insertions, 2 deletions
@@ -58,8 +58,13 @@ fn git_revision_hash() -> Option<String> { let result = process::Command::new("git") .args(&["rev-parse", "--short=10", "HEAD"]) .output(); - result.ok().map(|output| { - String::from_utf8_lossy(&output.stdout).trim().to_string() + result.ok().and_then(|output| { + let v = String::from_utf8_lossy(&output.stdout).trim().to_string(); + if v.is_empty() { + None + } else { + Some(v) + } }) } |