#!/bin/bash # clean-tree.sh — R-730 regression test for build-felhom-iso.sh's clean-tree gate. No docker, no ISO: # the gate runs right after argument parsing, so the build dies at the gate (refused) or at the next # check ("--pve-iso is required", which proves it got PAST the gate). The repo is a throwaway one # (FELHOM_ISO_REPO, the gate's test seam) with a local bare "origin". # 1. a clean tree whose HEAD = origin/main → passes the gate # 2. the same tree plus an UNTRACKED file → refused ("uncommitted or untracked") # 3. a commit that is NOT on origin/main → refused ("not origin/main") # 4. a modified TRACKED file → refused # Red-proof (run 2026-09-30, recorded in the R-730 row): delete the `[[ -z "$st" ]] || die …` line in # the gate → cases 2 and 4 FAIL (the build goes past the gate) → restore. set -uo pipefail HERE="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" BUILD="$HERE/../build-felhom-iso.sh" fail=0 check() { if eval "$2"; then echo " ok: $1"; else echo " FAIL: $1"; fail=1; fi; } S="$(mktemp -d "${TMPDIR:-/tmp}/felhom-cleantree-test.XXXXXX")" trap 'rm -rf "$S"' EXIT git init -q --bare "$S/origin.git" git init -q -b main "$S/repo" git -C "$S/repo" -c user.email=t@t -c user.name=t commit -q --allow-empty -m first git -C "$S/repo" remote add origin "$S/origin.git" git -C "$S/repo" push -q origin main run() { FELHOM_ISO_REPO="$S/repo" bash "$BUILD" 2>&1; } out="$(run)" check "1 clean + pushed passes the gate" '[[ "$out" == *"--pve-iso is required"* && "$out" != *"clean-tree gate:"*"R-730"* ]]' touch "$S/repo/stray.txt" out="$(run)" check "2 an untracked file is refused" '[[ "$out" == *"uncommitted or untracked"* && "$out" != *"--pve-iso is required"* ]]' rm -f "$S/repo/stray.txt" git -C "$S/repo" -c user.email=t@t -c user.name=t commit -q --allow-empty -m local-only out="$(run)" check "3 an unpushed commit is refused" '[[ "$out" == *"is not origin/main"* && "$out" != *"--pve-iso is required"* ]]' git -C "$S/repo" push -q origin main echo a > "$S/repo/f.txt"; git -C "$S/repo" add f.txt git -C "$S/repo" -c user.email=t@t -c user.name=t commit -q -m f; git -C "$S/repo" push -q origin main echo b > "$S/repo/f.txt" out="$(run)" check "4 a modified tracked file is refused" '[[ "$out" == *"uncommitted or untracked"* && "$out" != *"--pve-iso is required"* ]]' [[ $fail -eq 0 ]] && echo "clean-tree gate: all cases pass" || echo "clean-tree gate: FAILED" exit $fail