build.rs (315B)
1 use std::process::Command; 2 3 fn main() { 4 if let Ok(output) = Command::new("git").args(["rev-parse", "HEAD"]).output() { 5 if output.status.success() { 6 let hash = String::from_utf8_lossy(&output.stdout); 7 println!("cargo:rustc-env=GIT_COMMIT_HASH={}", hash.trim()); 8 } 9 } 10 }