parent
3d0436f18e
commit
e7a2c67998
@ -0,0 +1,35 @@
|
||||
use std::process::Command;
|
||||
|
||||
fn main() {
|
||||
println!("cargo:rustc-env=GIT_COMMIT_HASH={}", git_commit_hash());
|
||||
println!("cargo:rustc-env=GIT_TAG={}", git_tag());
|
||||
}
|
||||
|
||||
fn git_commit_hash() -> String {
|
||||
let commit_command = Command::new("git")
|
||||
.args(&[
|
||||
"rev-parse",
|
||||
"HEAD"
|
||||
])
|
||||
.output();
|
||||
|
||||
match commit_command {
|
||||
Ok(out) => String::from_utf8(out.stdout).unwrap_or(String::from("unknown")),
|
||||
Err(_) => String::from("unknown")
|
||||
}
|
||||
}
|
||||
|
||||
fn git_tag() -> String {
|
||||
let tag_command = Command::new("git")
|
||||
.args(&[
|
||||
"describe",
|
||||
"--tags",
|
||||
"--abbrev=0"
|
||||
])
|
||||
.output();
|
||||
|
||||
match tag_command {
|
||||
Ok(out) => String::from_utf8(out.stdout).unwrap_or(String::from("unknown")),
|
||||
Err(_) => String::from("unknown")
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue