on master help sign in
fix: Only parse git revision, don't use the tag for version
d3221b0Blaž Hrastnik
helix-term/build.rs+10−5
@@ -1,12 +1,17 @@
1+use std::borrow::Cow;
1use std::process::Command;
2use std::process::Command;
2
3
3fn main() {
4fn main() {
4 let git_hash = Command::new("git")
5 let git_hash = Command::new("git")
5− .args(&["describe", "--dirty"])
6+ .args(&["rev-parse", "HEAD"])
6 .output()
7 .output()
7− .map(|x| String::from_utf8(x.stdout).ok())
8 .ok()
8 .ok()
9− .flatten()
9+ .and_then(|x| String::from_utf8(x.stdout).ok());
10+
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(),
14+ };
15+
11− println!("cargo:rustc-env=VERSION_AND_GIT_HASH={}", git_hash);
16+ println!("cargo:rustc-env=VERSION_AND_GIT_HASH={}", version);
12}
17}