1
0
mirror of https://github.com/jht5945/finding.git synced 2025-12-27 13:20:03 +08:00

add git hash

This commit is contained in:
2019-08-02 01:18:36 +08:00
parent f376647b98
commit ec6589cf4f
2 changed files with 10 additions and 2 deletions

7
build.rs Normal file
View File

@@ -0,0 +1,7 @@
use std::process::Command;
fn main() {
// note: add error checking yourself.
let output = Command::new("git").args(&["rev-parse", "HEAD"]).output().unwrap();
let git_hash = String::from_utf8(output.stdout).unwrap();
println!("cargo:rustc-env=GIT_HASH={}", git_hash);
}

View File

@@ -14,14 +14,15 @@ use argparse::{ArgumentParser, StoreTrue, Store};
use rust_util::*;
const VERSION: &str = env!("CARGO_PKG_VERSION");
const GIT_HASH: &str = env!("GIT_HASH");
fn print_version() {
print!(r#"finding {}
print!(r#"finding {} - {}
Copyright (C) 2019 Hatter Jiang.
License MIT <https://opensource.org/licenses/MIT>
Written by Hatter Jiang
"#, VERSION);
"#, VERSION, &GIT_HASH[0..7]);
}
fn get_term_width() -> Option<usize> {