@@ -1,12 +1,17 @@
1+use std::borrow::Cow;
12use std::process::Command;
23
34fn main() {
45 let git_hash = Command::new("git")
5− .args(&["describe", "--dirty"])
6+ .args(&["rev-parse", "HEAD"])
67 .output()
7− .map(|x| String::from_utf8(x.stdout).ok())
88 .ok()
9− .flatten()
10− .unwrap_or_else(|| String::from(env!("CARGO_PKG_VERSION")));
11− println!("cargo:rustc-env=VERSION_AND_GIT_HASH={}", git_hash);
9+ .and_then(|x| String::from_utf8(x.stdout).ok());
10+
11+ let version: Cow<_> = match git_hash {
12+ Some(git_hash) => format!("{} ({})", env!("CARGO_PKG_VERSION"), &git_hash[..8]).into(),
13+ None => env!("CARGO_PKG_VERSION").into(),
14+ };
15+
16+ println!("cargo:rustc-env=VERSION_AND_GIT_HASH={}", version);
1217}