Your browser sucks, JavaScript disabled! Gunnar's console needs JavaScript and WebAssembly. Git over SSH on port 2222 does not.

nordisk/facett

.nornir/version-githash-stamp.md

facett-demo build stamp (version + git-hash)

The nordisk LAW: every shipped binary must be able to tell an operator WHICH build is running. facett-demo was the one facett binary still missing it — it had no build.rs and no --version. This note records how it now complies.

What was added

  1. facett-demo/build.rs — facett-demo's only build-time work. It reads the git metadata as plain files only (NO git, NO std::process::Command, NO shell — the pure-Rust zero-shell law) and emits cargo:rustc-env=FACETT_GIT_HASH=<short sha> (12 chars). It handles:

    • a normal .git directory,
    • a linked-worktree .git file (gitdir: <path> → the worktree gitdir, whose refs live in the shared commondir),
    • a workspace subdir (walks up from CARGO_MANIFEST_DIR to the repo root),
    • loose refs and the packed-refs fallback,
    • a detached HEAD (the sha is in HEAD directly),
    • and falls back to unknown (a crates.io tarball build has no .git), so env!("FACETT_GIT_HASH") always resolves.

cargo:rerun-if-changed is emitted for HEAD, the resolved loose ref, and packed-refs, so the stamp refreshes on commit/checkout without a clean rebuild.

  1. facett_demo::version_line() (in src/lib.rs) — returns facett-demo v<CARGO_PKG_VERSION> (<FACETT_GIT_HASH>), the single source of the stamp string.

  2. --version / -V (in src/main.rs, native main) — prints version_line() and return Ok(()) before eframe::NativeOptions / run_native, so it never brings up the viewport.

  3. Gallery header — draw_control_strip shows the stamp as a weak label beside the facett-demo heading (full line on hover), so the running build is visible in the live app too.

Proof

$ cargo build --release -p facett-demo --bin facett-demo
$ ./target/release/facett-demo --version
facett-demo v0.1.13 (003697de8dab)

The hash matches main HEAD 003697d.

Notes