verify-worktree: don't accept a stale real dir as a valid link on POSIX#489
Merged
Conversation
Invariant-2's `-d` fallback was meant only for Windows directory junctions
(which appear as plain dirs to bash). On macOS/Linux it also matched a stale
real directory at test_project/addons/godot_ai — a full copy of an old plugin
left by a self-update smoke test or botched checkout. The script saw plugin.gd
inside it, printed [ok], and exited 0 without repairing, so the developer/agent
silently tested OUTDATED plugin source.
Gate the `-d` fallback to Windows only (reusing the existing ${OS}/${OSTYPE}
detection). On POSIX a non-symlink directory now falls through to the existing
rm -rf + recreate-symlink path. Windows junction support is unchanged.
Add tests/unit/test_verify_worktree_link.py: drives the script against a
throwaway sandbox repo (real worktree untouched) covering stale-real-dir
repair, healthy-symlink pass-through, missing-link creation, and
wrong-target repair. POSIX-only.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…e test Satisfies the issue #397 lint (test_read_text_encoding) that the initial commit tripped in CI. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR tightens script/verify-worktree so POSIX worktrees no longer accept a stale real directory as a valid test_project/addons/godot_ai plugin link.
Changes:
- Adds Windows-only gating for the directory fallback used to accept junctions.
- Adds POSIX unit coverage for stale directory repair, healthy symlinks, missing links, and wrong-target symlinks.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
script/verify-worktree |
Restricts plain-directory acceptance to Windows junction scenarios. |
tests/unit/test_verify_worktree_link.py |
Adds sandboxed pytest coverage for link creation and repair behavior. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
script/verify-worktree's Invariant-2 check has a macOS/Linux blind spot. The linktest_project/addons/godot_aishould be a symlink into this worktree'splugin/addons/godot_ai(or, on Windows, a directory junction).The
elif [ -d "$link" ]fallback was meant only to accept genuine Windows directory junctions, which appear as plain dirs to bash. But on macOS/Linux it also matched a stale real directory — a full copy of an old plugin left behind by a self-update smoke test or a botched checkout. The script sawplugin.gdinside it, printed[ok], and exited 0 without repairing — so a developer/agent silently tested OUTDATED plugin source. Hit in practice: a stale copy lacked a branch'sgame_helper.gdfix while[ok]was printed.Fix
Gate the
-dfallback to Windows only, reusing the same${OS}/${OSTYPE}detection the script already uses for link creation. On POSIX, a non-symlink directory now falls through to the existingrm -rf "$link"+ recreate-symlink path. Windows junction support (junctions look like plain dirs to bash, matched viaplugin.gdpresence) is unchanged.Tests
New
tests/unit/test_verify_worktree_link.pydrives the script against a throwaway sandbox repo (the real worktree's link is never touched), POSIX-only:plugin.gd, not the stale copy)[ok], idempotent)All 4 pass;
ruff checkclean;bash -nsyntax-ok.Manual repro
🤖 Generated with Claude Code