From d8a4a2733a9d4a4ce2d6849ca7751957f509c775 Mon Sep 17 00:00:00 2001 From: sneak Date: Wed, 18 Nov 2026 21:44:44 +0000 Subject: [PATCH] test/update-policy.sh: check that other staged changes stay out of the commit The script commits only the listed paths, but no test staged anything else, so dropping the pathspec from its git commit left the tests green while the commit swept in whatever the person had staged. The first scenario now stages a change to README.md and checks that the commit holds only the listed files and that the change is still staged. Model: opus-5-5 --- test/update-policy.sh | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/test/update-policy.sh b/test/update-policy.sh index 7289c65..17d67f8 100755 --- a/test/update-policy.sh +++ b/test/update-policy.sh @@ -51,6 +51,8 @@ new_repo() { new_repo "a first run writes and commits exactly the listed files" echo stray > stray.txt +echo staged >> README.md +git add README.md script/update-policy > "$dir/output" 2>&1 || fail "exited non-zero" [ "$(git rev-list --count HEAD)" = 2 ] || fail "made no single commit" [ "$(git show --name-only --format= HEAD | sort)" = \ @@ -58,7 +60,8 @@ script/update-policy > "$dir/output" 2>&1 || fail "exited non-zero" cmp -s docs/REPO_POLICIES.md "$PROMPTS/prompts/REPO_POLICIES.md" || fail "REPO_POLICIES.md differs" [ -x script/update-policy ] || fail "script not executable" -[ "$(git status --porcelain)" = "?? stray.txt" ] || fail "tree not clean" +[ "$(git status --porcelain)" = "$(printf 'M README.md\n?? stray.txt')" ] || + fail "changed files outside the list" scenario="a second run commits nothing" script/update-policy > "$dir/output" 2>&1 || fail "exited non-zero"