summaryrefslogtreecommitdiffstats
path: root/build.rs
diff options
context:
space:
mode:
authorAndrew Gallant <jamslam@gmail.com>2018-02-20 19:46:47 -0500
committerAndrew Gallant <jamslam@gmail.com>2018-02-20 20:05:55 -0500
commitfe9be658f410d2e35c1cfe236a338f95aa03a724 (patch)
tree5b4215c2b532094bab8eacc8387cc5d49932a12b /build.rs
parent8c800adab7ca441519e4bc503450123a80923c41 (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.rs9
1 files changed, 7 insertions, 2 deletions
diff --git a/build.rs b/build.rs
index 81fb4873..b7f26f17 100644
--- a/build.rs
+++ b/build.rs
@@ -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)
+ }
})
}