multiversx_sc_meta_lib/tools/
git_describe.rs

1use std::process::{Command, Output};
2
3pub fn git_describe() -> String {
4    Command::new("git")
5        .args(["describe"])
6        .output()
7        .map(git_describe_process_output)
8        .unwrap_or_default()
9}
10
11fn git_describe_process_output(output: Output) -> String {
12    if output.status.success() {
13        let mut result = String::from_utf8(output.stdout).unwrap_or_default();
14        if result.ends_with('\n') {
15            // for some reason we get a trailing newline
16            let _ = result.pop();
17        }
18        result
19    } else {
20        String::new()
21    }
22}