From fe9be658f410d2e35c1cfe236a338f95aa03a724 Mon Sep 17 00:00:00 2001 From: Andrew Gallant Date: Tue, 20 Feb 2018 19:46:47 -0500 Subject: [PATCH] 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 --- build.rs | 9 +++++++-- 1 file 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 { 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) + } }) }