agent-first-slug 0.4.0

Rust slug generation with explicit caller configuration for path and URL path segments.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
fn main() {
    println!("cargo:rustc-env=DISPLAY_NAME=Agent-First Slug");
    println!("cargo:rustc-env=GIT_SHA={}", git_sha());
}

/// Short commit SHA of the tree this was built from, or `"unknown"` when no
/// `.git` is reachable (a crates.io source tarball, for example).
fn git_sha() -> String {
    std::process::Command::new("git")
        .args(["rev-parse", "--short", "HEAD"])
        .output()
        .ok()
        .filter(|output| output.status.success())
        .and_then(|output| String::from_utf8(output.stdout).ok())
        .map(|sha| sha.trim().to_string())
        .filter(|sha| !sha.is_empty())
        .unwrap_or_else(|| "unknown".to_string())
}