Skip to content

Commit

Permalink
add git hash
Browse files Browse the repository at this point in the history
  • Loading branch information
jht5945 committed Aug 1, 2019
1 parent e873954 commit 808730b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
7 changes: 7 additions & 0 deletions build.rs
Original file line number Diff line number Diff line change
@@ -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);
}
5 changes: 3 additions & 2 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,15 @@ use chrono::prelude::*;
use rust_util::*;

const VERSION: &str = env!("CARGO_PKG_VERSION");
const GIT_HASH: &str = env!("GIT_HASH");

fn print_version() {
print!(r#"show {}
print!(r#"show {} - {}
Copyright (C) 2019 Hatter Jiang.
License MIT <https://opensource.org/licenses/MIT>
Written by Hatter Jiang
"#, VERSION);
"#, VERSION, &GIT_HASH[0..7]);
}

fn show_ip(verbose: bool) -> XResult<()> {
Expand Down

0 comments on commit 808730b

Please sign in to comment.