feat: embed git SHA in version string via build.rs
Adds a build.rs that runs `git describe --tags --always --dirty` and
sets NUMA_BUILD_VERSION at compile time. A new `numa::version()` helper
returns the build version, falling back to CARGO_PKG_VERSION when git
is unavailable (source tarballs, Docker builds without .git).
Version strings:
tagged release: 0.13.1
commits ahead: 0.13.1+a87f907
uncommitted changes: 0.13.1+a87f907-dirty
no git: 0.13.1
Replaces all 6 inline env!("CARGO_PKG_VERSION") call sites with the
single version() function.
This commit is contained in:
10
src/main.rs
10
src/main.rs
@@ -72,7 +72,7 @@ async fn main() -> numa::Result<()> {
|
||||
};
|
||||
}
|
||||
"version" | "--version" | "-V" => {
|
||||
eprintln!("numa {}", env!("CARGO_PKG_VERSION"));
|
||||
eprintln!("numa {}", numa::version());
|
||||
return Ok(());
|
||||
}
|
||||
"help" | "--help" | "-h" => {
|
||||
@@ -383,12 +383,10 @@ async fn main() -> numa::Result<()> {
|
||||
};
|
||||
|
||||
// Title row: center within the box
|
||||
let title = format!(
|
||||
"{b}NUMA{r} {it}DNS that governs itself{r} {d}v{}{r}",
|
||||
env!("CARGO_PKG_VERSION")
|
||||
);
|
||||
let ver = numa::version();
|
||||
let title = format!("{b}NUMA{r} {it}DNS that governs itself{r} {d}v{ver}{r}",);
|
||||
// The title contains ANSI codes; visible length is ~38 chars. Pad to fill the box.
|
||||
let title_visible_len = 4 + 2 + 24 + 2 + 1 + env!("CARGO_PKG_VERSION").len() + 1;
|
||||
let title_visible_len = 4 + 2 + 24 + 2 + 1 + ver.len() + 1;
|
||||
let title_pad = w.saturating_sub(title_visible_len);
|
||||
eprintln!("\n{o} ╔{bar_top}╗{r}");
|
||||
eprint!("{o} ║{r} {title}");
|
||||
|
||||
Reference in New Issue
Block a user