fix: --version no longer false-positives -dirty on clean release installs
All checks were successful
Build / validate (push) Successful in 6m13s

The build-time dirty check used `git status --porcelain`, which counts
untracked files — including cargo's own `.cargo-ok` marker in a
`cargo install --git` checkout — so a clean tagged build reported e.g.
`1.0.1 (bcab3c16b-dirty)`. Use `git diff --quiet HEAD` (tracked changes only).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
Erich Blume 2026-06-04 10:20:23 -07:00
commit 1603b37f74
2 changed files with 10 additions and 5 deletions

View file

@ -35,10 +35,14 @@ fn git_short_sha() -> Option<String> {
if sha.is_empty() { if sha.is_empty() {
return None; return None;
} }
let dirty = Command::new("git") // Tracked changes only. `git status --porcelain` would also count
.args(["status", "--porcelain"]) // untracked files — including cargo's own `.cargo-ok` marker in a
.output() // `cargo install --git` checkout — and falsely tag a clean release build
.map(|o| !o.stdout.is_empty()) // `-dirty`. `git diff --quiet HEAD` exits non-zero only on tracked edits.
.unwrap_or(false); let dirty = !Command::new("git")
.args(["diff", "--quiet", "HEAD"])
.status()
.map(|s| s.success())
.unwrap_or(true);
Some(if dirty { format!("{sha}-dirty") } else { sha }) Some(if dirty { format!("{sha}-dirty") } else { sha })
} }

View file

@ -0,0 +1 @@
Fix `heph`/`hephd` `--version` falsely showing a `-dirty` suffix on clean release installs. The build-time dirty check now considers only tracked modifications (`git diff --quiet HEAD`) instead of counting untracked files such as cargo's own `.cargo-ok` marker in a `cargo install --git` checkout.