on master help sign in
Add commit hash to version info, if present (#957)

* Add commit hash to version info, if present * Rename GIT_HASH to indicate that it includes version, fix linter error * Add whitespace after use statement Co-authored-by: Ivan Tham <pickfire@riseup.net> Co-authored-by: Ivan Tham <pickfire@riseup.net>

commit0949a0de7fec9e11f8011693f84b1939b0a6a548 authorGygaxis Vainhardt <44003709+AloeareV@users.noreply.github.com> dateSun 14 Nov 2021, 11:09 (5 years ago) parentb74912e
2 files changed+14−2
helix-term/build.rs+12 helix-term/src/main.rs+2−2
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:
6666 -V, --version Prints version information
6767",
6868 env!("CARGO_PKG_NAME"),
69− env!("CARGO_PKG_VERSION"),
69+ env!("VERSION_AND_GIT_HASH"),
7070 env!("CARGO_PKG_AUTHORS"),
7171 env!("CARGO_PKG_DESCRIPTION"),
7272 logpath.display(),
@@ -81,7 +81,7 @@ FLAGS:
8181 }
8282
8383 if args.display_version {
84− println!("helix {}", env!("CARGO_PKG_VERSION"));
84+ println!("helix {}", env!("VERSION_AND_GIT_HASH"));
8585 std::process::exit(0);
8686 }
8787