Files
Ansho ReiandClaude Opus 5 73ffcad733 Reformat with cargo fmt, and nothing else
Layout only, no behaviour and no wording. 161 hunks across 22 files, 98 of them
rustfmt joining a call or a message onto the one line it fits on. The config it
formats to, and how its four numbers were arrived at, is the commit before this
one.

Separate so that it is reviewable by not being read: nothing here is a decision,
and every decision is next door.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-23 00:23:04 +02:00

39 lines
1.1 KiB
Rust

//! Stamps the build with the commit it came from.
//!
//! The crate version alone cannot tell a stale install from a fresh build: it is
//! pinned at 0.1.0 and nobody bumps it per install, so both binaries claim the
//! same thing. The short sha is what makes `worklane --version` able to answer
//! "is this the binary with the fix in it".
//!
//! Absent a git directory, as when installing from a published crate, the sha is
//! "unknown" rather than a build failure.
use std::process::Command;
fn main() {
// Without these, an incremental build keeps stamping the sha it first saw.
println!("cargo:rerun-if-changed=.git/HEAD");
println!("cargo:rerun-if-changed=.git/refs");
println!("cargo:rustc-env=WORKLANE_GIT_SHA={}", git_sha());
}
fn git_sha() -> String {
let output = Command::new("git")
.args(["rev-parse", "--short", "HEAD"])
.output();
let sha = match output {
Ok(output) if output.status.success() => {
String::from_utf8_lossy(&output.stdout).trim().to_string()
}
_ => String::new(),
};
if sha.is_empty() {
"unknown".to_string()
} else {
sha
}
}