gitoxide 0.44.0

A command-line application for interacting with git repositories
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
use std::process::Command;

fn main() {
    let version = Command::new(if cfg!(windows) { "git.exe" } else { "git" })
        .args(["describe", r"--match=v*\.*\.*"])
        .output()
        .ok()
        .and_then(|out| parse_describe(&out.stdout))
        .unwrap_or_else(|| env!("CARGO_PKG_VERSION").into());

    println!("cargo:rustc-env=GIX_VERSION={version}");
}

fn parse_describe(input: &[u8]) -> Option<String> {
    let input = std::str::from_utf8(input).ok()?;
    input.trim().to_owned().into()
}