1
use std::process::Command;
2

            
3
4
fn main() {
4
4
    let output = Command::new("git")
5
4
        .args(["rev-parse", "--short", "HEAD"])
6
4
        .output()
7
4
        .expect("Failed to get git revision");
8

            
9
4
    let revision = String::from_utf8(output.stdout)
10
4
        .expect("Invalid UTF-8 in git output")
11
4
        .trim()
12
4
        .to_owned();
13

            
14
4
    println!("cargo:rustc-env=GIT_REVISION={revision}");
15
4
    println!("cargo:rerun-if-changed=.git/HEAD");
16
4
}