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