on master help sign in
Add commit hash to version info, if present (#957)
0949a0dGygaxis Vainhardt
helix-term/build.rsnew file+12
@@ -0,0 +1,12 @@
1+use std::process::Command;
2+
3+fn main() {
4+ let git_hash = Command::new("git")
5+ .args(&["describe", "--dirty"])
6+ .output()
7+ .map(|x| String::from_utf8(x.stdout).ok())
8+ .ok()
9+ .flatten()
10+ .unwrap_or_else(|| String::from(env!("CARGO_PKG_VERSION")));
11+ println!("cargo:rustc-env=VERSION_AND_GIT_HASH={}", git_hash);
12+}
helix-term/src/main.rs+2−2
@@ -66,7 +66,7 @@ FLAGS:
66 -V, --version Prints version information
66 -V, --version Prints version information
67",
67",
68 env!("CARGO_PKG_NAME"),
68 env!("CARGO_PKG_NAME"),
69− env!("CARGO_PKG_VERSION"),
69+ env!("VERSION_AND_GIT_HASH"),
70 env!("CARGO_PKG_AUTHORS"),
70 env!("CARGO_PKG_AUTHORS"),
71 env!("CARGO_PKG_DESCRIPTION"),
71 env!("CARGO_PKG_DESCRIPTION"),
72 logpath.display(),
72 logpath.display(),
@@ -81,7 +81,7 @@ FLAGS:
81 }
81 }
82
82
83 if args.display_version {
83 if args.display_version {
84− println!("helix {}", env!("CARGO_PKG_VERSION"));
84+ println!("helix {}", env!("VERSION_AND_GIT_HASH"));
85 std::process::exit(0);
85 std::process::exit(0);
86 }
86 }
87
87