Review r4: inherited GIT_TRACE* survived sanitization, and a trace aimed at
/dev/stdout corrupted the captured SHA and status ("local", dirty). This
was the third surviving-GIT_* finding, so close the class: drop every
inherited GIT_* variable and set only GIT_OPTIONAL_LOCKS=0,
GIT_TERMINAL_PROMPT=0 and GIT_NO_LAZY_FETCH=1.
The sanitizer test now requires exactly those three GIT_* names (including
when an unknown GIT_* control is inherited). A real-git regression test
aims each of GIT_TRACE, GIT_TRACE_SETUP, GIT_TRACE2, GIT_TRACE2_EVENT and
GIT_TRACE2_PERF at /dev/stdout and requires the checkout's clean HEAD.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Review r3: GIT_REDIRECT_STDIN/STDOUT/STDERR survived sanitization. On Git
for Windows, GIT_REDIRECT_STDOUT sends output past the capture pipe, so a
dirty tree would read as clean and HEAD could fall back to "local".
Drop them, and GIT_CONFIG_NOSYSTEM, which the documented list already
claimed. Set GIT_TERMINAL_PROMPT=0 and GIT_NO_LAZY_FETCH=1 and run git
with stdin closed. The sanitizer test asserts all of these.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Review r2: inherited GIT_DIR / GIT_WORK_TREE / GIT_INDEX_FILE and similar
variables override git -C, so the resolver could report another
repository's HEAD or dirty state. Drop every repository-, index-,
object-store-, namespace- and config-selecting variable before running
git, and set GIT_OPTIONAL_LOCKS=0 so status never writes the index.
The real-repository test fixture builds its git environment from the same
helper (plus stripping any other GIT_* variable) so the two cannot drift.
A new test redirects GIT_DIR/GIT_WORK_TREE/GIT_INDEX_FILE to a second
repository, with and without an invalid GITHUB_SHA, and requires the
checkout's own HEAD and dirty state.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Review r1: a non-empty but invalid GITHUB_SHA short-circuited the
resolver to "local" even when the repository HEAD was valid. Validate
each source on its own and fall back to "local" only if both fail.
Move the git helpers to scripts/conditional_gate_metadata.py and use them
from conditional_gate_summary.py too, so the workflow summary records the
same git_sha and git_dirty. Add summary-producer cases and a real
temporary-repository test for clean, tracked-dirty and untracked states.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>