Repository navigation
fix(repo): make check-affected list a branch's changes from any directory and fail on an empty list - #9072
Conversation
…tory and fail on an empty list check-affected.sh took the tree to check from the working directory. Run by path from a worktree while the shell sat in the main checkout, it checked the main checkout, whose HEAD was at its merge-base with origin/main, found 0 changed files, skipped the tests as a foreign tree, and passed. That is the "7 passed, 7 skipped over 0 changed files" the ready gate recorded on #9041, #9048 and #9062, explicit --base included. The tree checked is now CHECK_DATA_ROOT's, else the one holding the script, as in the other check scripts. The pre-push hook names the branch tree for its merge-base copy, and the --uncommitted run names its snapshot. An empty changed set while HEAD is not the base exits 2 with a message instead of passing; --uncommitted with no edits checks HEAD itself so it still passes. Closes #9051 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
typos 1.51 reads `[nd]` as a misspelling of "and" and the pre-push check blocks any branch that touches the hook; `[dn]` matches the same flags. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Compose both new --uncommitted test cases in scripts/check-affected.test.sh: the branch's CHECK_DATA_ROOT case and main's CHECK_AFFECTED_SCRIPT_EXEC_BIT case (#9100). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
claude-security-review reviewed Security review of PR #9072 (head 6b679e5)Findings: 0. The PR changes I looked at four places where the change could cross a trust boundary:
The pre-push hook edit reorders |
|
claude-review reviewed No findings on PR #9072 at 6b679e5. What I checked (by reading the diff,
Closing issue #9051. Both acceptance criteria are met, and the new tests would fail if either broke. The third fix bullet (why an explicit Not verified. I did not run the test suites; the PASS counts in the PR body are author-claimed. My shell was restricted, so I could not grep the repository for other callers of |
Closes #9051
Summary
scripts/check-affected.sh --testsreported "0 changed files" on branches that changed files and then passed, so the ready phase's verify gate checked nothing. Now it checks the branch it belongs to whatever the working directory is. An empty changed set while HEAD is not the base exits 2 with a message instead of passing.Fix
Root cause: the script picked the tree to check from the shell's working directory (
git rev-parse --show-toplevelwith no-C,scripts/check-affected.sh:97-101onmain), not from where the script lives. Every run in this repository's session transcripts that reported 0 changed files had the shapebash <worktree>/scripts/check-affected.sh --testswith the working directory in the main checkout. Runs started inside the worktree (env -C <worktree> bash scripts/check-affected.sh) listed the branch's files. In that shape the script checked the main checkout. The main checkout's HEAD sat at its merge-base withorigin/main, so the diff was empty. The worktree counted as a foreign tree, sotestswas skipped. Rerunning that shape against #9062's worktree printed exactly the7 passed, 7 skipped over 0 changed filesthat #9062 reported. #9051 reports the same 0 changed files for #9041 and #9048. The explicit--base origin/mainruns were made from the main checkout too, so--basewas the same cause, not a second bug.scripts/check-affected.shchecks the treeCHECK_DATA_ROOTnames, else the tree holding the script, which is the convention the other check scripts already follow (${CHECK_DATA_ROOT:-$SCRIPT_DIR/..}).--uncommittedpassesCHECK_DATA_ROOTto its snapshot run, so the issue lane's wrapper, which setsCHECK_DATA_ROOTto the checkout, still checks the snapshot. With no edits, the snapshot is HEAD itself, so it still passes..claude/hooks/check-affected-pre-push.shpassesCHECK_DATA_ROOT="$data"to the script it runs. Its merge-base copy sits outside any work tree, so without this the copy would exit 2, which the hook treats as a pass. The hook's short-flag glob is also reordered from[nd]to[dn](same match), because typos 1.51 flagsnd, and the pre-push check blocks any branch that touches the file.Verification
Red: the new cases in
scripts/check-affected.test.shrun againstmain's script:The other 5 failures are the copy cases, which now pass
CHECK_DATA_ROOT(the hook's new contract), andmain's script ignores it.Green, with the fix:
scripts/check-affected.test.shPASS=46 FAIL=0;.claude/hooks/check-affected-pre-push.test.shPASS=51 FAIL=0, including the real merge-base copy blocking a shellcheck error;scripts/check-data-root.test.shPASS=8 FAIL=0;scripts/lib/gate-entry.test.shPASS=33 FAIL=0;scripts/check-affected-gates.test.shPASS=7 FAIL=0.Run in the shape that failed (working directory in the main checkout, the script in this worktree), the fixed script listed this branch's 3 files and ran the checks over them. That run exited 1 on two findings:
[nd]glob in the hook. e51d6e5 fixes it, and the pre-push check then passed.scripts/check-script-contract.test.sh, atcheck-html-assets.sh: htmlhint not found ... (run npm ci). This fresh worktree has nonode_modules. That failure has nothing to do with this change.Every other selected suite passed.
Related
🤖 Generated with Claude Code