diff --git a/CHANGELOG.md b/CHANGELOG.md index b2852bc..3392eaf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,18 @@ All notable changes to this project are documented here, following ## [Unreleased] +## [0.2.1] - 2026-11-04 + +### Fixed + +- **A passing Gatehouse review failed the push whenever there was a diff to + review.** `run_in_image` never reset its exit-status variable, and shell + function variables are global, so `git diff --quiet` -- which exits 1 + whenever there IS a diff -- left a 1 that the container's success never + overwrote. Every push with a branch to review printed "No issues found" and + then failed. Present since v0.1.0; found on trentina's first push through + v0.2.0. `tests/test_host_contract.sh` now holds it. + ## [0.2.0] - 2026-11-04 ### Changed @@ -153,6 +165,7 @@ cached tag was never refreshed — that gate had been running a two-week-old reviewer while CI pulled fresh. Local and CI were different reviewers on the same diff. -[Unreleased]: https://github.com/crunchtools/python-sdlc/compare/v0.2.0...HEAD +[Unreleased]: https://github.com/crunchtools/python-sdlc/compare/v0.2.1...HEAD +[0.2.1]: https://github.com/crunchtools/python-sdlc/releases/tag/v0.2.1 [0.2.0]: https://github.com/crunchtools/python-sdlc/releases/tag/v0.2.0 [0.1.0]: https://github.com/crunchtools/python-sdlc/releases/tag/v0.1.0 diff --git a/Containerfile b/Containerfile index f882c22..b15bb3d 100644 --- a/Containerfile +++ b/Containerfile @@ -44,7 +44,7 @@ LABEL description="Every CrunchTools Python SDLC check in one image: ruff, mypy, LABEL org.opencontainers.image.source="https://github.com/crunchtools/python-sdlc" LABEL org.opencontainers.image.description="Every CrunchTools Python SDLC check in one image." LABEL org.opencontainers.image.licenses="AGPL-3.0-or-later" -LABEL version="0.2.0" +LABEL version="0.2.1" # What the image carries, readable without starting anything. `sdlc versions` # prints these and a consuming repo's CI pins them. diff --git a/IMAGE_TAG b/IMAGE_TAG index 0ea3a94..0c62199 100644 --- a/IMAGE_TAG +++ b/IMAGE_TAG @@ -1 +1 @@ -0.2.0 +0.2.1 diff --git a/README.md b/README.md index bf6df20..557cdcd 100644 --- a/README.md +++ b/README.md @@ -36,7 +36,7 @@ default_install_hook_types: [pre-commit, pre-push] repos: - repo: https://github.com/crunchtools/python-sdlc - rev: v0.2.0 + rev: v0.2.1 hooks: - id: sdlc-commit - id: sdlc-push diff --git a/bin/sdlc b/bin/sdlc index 065d3e1..32b7329 100755 --- a/bin/sdlc +++ b/bin/sdlc @@ -164,12 +164,16 @@ run_in_image() { ${SDLC_GATEHOUSE_SAMPLES:+-e SDLC_GATEHOUSE_SAMPLES} \ "$@" + # Reset HERE, not inherited. A shell function's variables are global, so a + # caller's earlier `|| _rc=$?` -- t_gatehouse's `git diff --quiet`, which is 1 + # whenever there IS a diff -- survived into this function, and a container + # that succeeded reported the caller's 1 as its own failure. + _rc=0 if [ "$_stdin" = stdin ]; then podman "$@" || _rc=$? else podman "$@" "$SHIM/podman" <> "$LOG" case " \$* " in + *" plan gatehouse-direct "*) + printf 'gatehouse${TAB}local${TAB}gatehouse\n' ;; *" plan evil "*) printf 'evil${TAB}host${TAB}sh${US}-c${US}touch $SHIM/pwned\n' ;; *" plan subst "*) @@ -111,6 +113,39 @@ else bad "a host step's word was evaluated as shell" fi +# A container that succeeds must report success, whatever the caller's last +# exit status was. Gatehouse runs right after `git diff --quiet`, which exits 1 +# whenever there IS a diff to review; that 1 leaked through a shared variable +# and failed every push with a branch to review, after printing "No issues +# found". Checked here with a git shim that has a diff and a podman that passes. +GITSHIM=$(mktemp -d) +for prog in pre-commit gh; do + [ -e "$SHIM/$prog" ] && ln -s "$SHIM/$prog" "$GITSHIM/$prog" +done +for prog in sh awk sed tr grep basename dirname nproc cat mktemp rm ln head id podman; do + [ -e "$SHIM/$prog" ] && ln -s "$(readlink -f "$SHIM/$prog")" "$GITSHIM/$prog" +done +cat > "$GITSHIM/git" < "$ENVFILE" +PATH="$GITSHIM" GATEHOUSE_ENV="$ENVFILE" sh bin/sdlc gatehouse-direct >/dev/null 2>&1 && rc=0 || rc=$? +rm -rf "$GITSHIM" +if [ "$rc" -eq 0 ]; then + ok "a passing review after a non-empty diff reports success" +else + bad "a passing review after a non-empty diff exited $rc" +fi + # The targets that run a container must actually have tried to. Without this the # loop above would also pass if every target silently did nothing. if [ -s "$LOG" ]; then