diff options
Diffstat (limited to 'helix-term')
-rw-r--r-- | helix-term/build.rs | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/helix-term/build.rs b/helix-term/build.rs index 61ffa6f4..21dd5612 100644 --- a/helix-term/build.rs +++ b/helix-term/build.rs @@ -1,12 +1,17 @@ +use std::borrow::Cow; use std::process::Command; fn main() { let git_hash = Command::new("git") - .args(&["describe", "--dirty"]) + .args(&["rev-parse", "HEAD"]) .output() - .map(|x| String::from_utf8(x.stdout).ok()) .ok() - .flatten() - .unwrap_or_else(|| String::from(env!("CARGO_PKG_VERSION"))); - println!("cargo:rustc-env=VERSION_AND_GIT_HASH={}", git_hash); + .and_then(|x| String::from_utf8(x.stdout).ok()); + + let version: Cow<_> = match git_hash { + Some(git_hash) => format!("{} ({})", env!("CARGO_PKG_VERSION"), &git_hash[..8]).into(), + None => env!("CARGO_PKG_VERSION").into(), + }; + + println!("cargo:rustc-env=VERSION_AND_GIT_HASH={}", version); } |