Repository navigation
fix(pstack): protect untracked and ignored worktree files - #459
dajiaohuang wants to merge 4 commits into
Conversation
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.
Bugbot Autofix is ON, but it could not run because the branch was deleted or merged before autofix could start.
Reviewed by Cursor Bugbot for commit a17c461. Configure here.
|
Verified on a test repo. A worktree with one untracked note plus an ignored Two non-blocking suggestions:
Related: #470 touches the same script. It covers closed unmerged PRs and unpushed commits bucketed as |
… work as safe Three problems in worktree-audit.sh (cursor#470): - a PR in any non-open state satisfied `$pr != "-"`, so a CLOSED (unmerged) PR made the worktree `safe`; - the computed `remote` column (ahead/no-remote/detached) was never read by the bucket logic, so unpushed commits could be bucketed `safe`; - the header called the script read-only although it runs `git fetch`. Only ancestry of origin/main or a MERGED PR now counts as proof the work exists elsewhere. Worktrees whose HEAD is ahead of / absent from the remote or detached and not on origin/main go to a new `hold-unpushed` bucket, ranked right after hold-wip and hold-open-pr. A CLOSED PR falls through to `review`. The header now states the one write the script performs, and the playbook documents the new bucket in step 1 (steps 4-5 are left untouched to avoid conflicting with cursor#459). Verified on a synthetic repo with a stubbed gh: ahead1+CLOSED and detached off-main -> hold-unpushed; pushed+MERGED, pushed+CLOSED-on-main and detached on origin/main -> safe; pushed+CLOSED with commits not on main -> review. Fixes cursor#470
… work as safe Three problems in worktree-audit.sh (cursor#470): - a PR in any non-open state satisfied `$pr != "-"`, so a CLOSED (unmerged) PR made the worktree `safe`; - the computed `remote` column (ahead/no-remote/detached) was never read by the bucket logic, so unpushed commits could be bucketed `safe`; - the header called the script read-only although it runs `git fetch`. Only ancestry of origin/main or a MERGED PR now counts as proof the work exists elsewhere. Worktrees whose HEAD is ahead of / absent from the remote or detached and not on origin/main go to a new `hold-unpushed` bucket, ranked right after hold-wip and hold-open-pr. A CLOSED PR falls through to `review`. The header now states the one write the script performs, and the playbook documents the new bucket in step 1 (steps 4-5 are left untouched to avoid conflicting with cursor#459). Verified on a synthetic repo with a stubbed gh: ahead1+CLOSED and detached off-main -> hold-unpushed; pushed+MERGED, pushed+CLOSED-on-main and detached on origin/main -> safe; pushed+CLOSED with commits not on main -> review. Fixes cursor#470
|
Hey @dajiaohuang, a note for whoever reviews this. #459 and #492 edit the same two files ( |

Summary
Fixes #449.
Validation
Note
Low Risk
Documentation and read-only audit script changes only; deletion behavior is stricter and safer for local worktrees, with no production runtime impact.
Overview
Tightens worktree cleanup so untracked and ignored paths are never treated as disposable scratch.
The audit script now runs
git statuswith--untracked-files=alland--ignored=matching, labels any dirty worktree aswip:N(line count of all paths), and drops the oldscratchbucket. The playbook adds an explicit ownership/safety framing and rewrites steps 4–5: default to holding anywipworktree, require per-path user approval before removal, use non-forcegit worktree removeonly after a fresh status preflight, and forbidrm -rforgit worktree pruneto override Git refusals.Reviewed by Cursor Bugbot for commit f5752d5. Bugbot is set up for automated code reviews on this repo. Configure here.