add version command

This commit is contained in:
2025-02-17 17:35:37 -05:00
parent d3778461d8
commit 8ea2bcb2e2
3 changed files with 25 additions and 0 deletions

15
build.rs Normal file
View File

@@ -0,0 +1,15 @@
use std::process::Command;
fn main() {
// get
let output = Command::new("git").args(&["rev-parse", "--short", "HEAD"]).output()
.expect("git rev-parse HEAD failed");
let hash = String::from_utf8(output.stdout).expect("not UTF-8 output");
let output = Command::new("git").args(&["rev-parse", "--abbrev-ref", "HEAD"]).output()
.expect("git rev-parse HEAD failed");
let branch = String::from_utf8(output.stdout).expect("not UTF-8 output");
println!("cargo:rustc-env=GIT_HASH={}", hash);
println!("cargo:rustc-env=GIT_BRANCH={}", branch);
}