fn main() { // Make the current git hash available to the build. if let Some(rev) = git_revision_hash() { println!("cargo:rustc-env=REBAR_REVISION={}", rev); } } fn git_revision_hash() -> Option { let result = std::process::Command::new("git") .args(&["rev-parse", "--short=10", "HEAD"]) .output(); result.ok().and_then(|output| { let v = String::from_utf8_lossy(&output.stdout).trim().to_string(); if v.is_empty() { None } else { Some(v) } }) }