aboutsummaryrefslogtreecommitdiffstats
path: root/build.rs
blob: ee9d9e3da01df1f7e83f94a7ebcd19c05e5157b0 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
fn main() {
    println!("cargo:rustc-env=FANCY_PROMPT_BUILD_GIT_REV={}", git_describe())
}

fn git_describe() -> String {
    let output = std::process::Command::new("git")
        .args(&["describe", "--tags"])
        .output();
    output.and_then(|output| {
        if output.status.success() {
            Ok(
                String::from_utf8_lossy(&output.stdout)
                    .trim()
                    .to_string()
            )
        }
        else {
            Err(
                std::io::Error::new(
                    std::io::ErrorKind::Other,
                    "failed to run git"
                )
            )
        }
    }).unwrap_or_else(|_err| {
        // String::from(format!("{}", _err))
        String::from("???")
    })
}