Repository navigation
fix(repos): prune keeps worktrees with data or outside its folder - #6477
Conversation
e10d382 to
a745746
Compare
|
An agent took over the Service plan of #6435 and delivered it on this branch: a plan revision, the build (tests first), a separate read-only review, and the fixes of that review. This pull request is now the delivery pull request. The 5 findings of the plan state comment
Design change: count only ignored data files On 2026-11-19, 12 used worktrees of this repository each held 70 to 165 ignored paths, nearly all of them caches (881 Fixes of the build review (7 findings)
Read-only preview on the real repository (no
The 1 data file of Checks
The pull request stays a draft until a person reviews the diff in tuicr ( |
Check resultsHead commit:
Fail-to-pass run: https://github.com/dan-petty/devops-cli/actions/runs/44658518944/job/136030624975 Skipped check: Plan Check |
Resolve the five review findings of the Service plan and count only the ignored data files: an ignored file that is not a regenerable cache or build output keeps a worktree. The folder refusal comes before the missing-directory rule, also for a prunable record. Each task group lists every caller of a changed signature and runs every test file that it changes.
Five tests fail on the branch before the fix: a note whose name starts with .coverage, a directory that git cannot open, a data file written after the decision (prune and the reclaim), and an untracked file that status.showUntrackedFiles=no hides. The GitHub fake gets a before_answer hook that runs on each request before its answer.
Prune asks the scope rule again right before each removal, because the decision pass reads GitHub for each worktree first. A warning of git ls-files makes the count of ignored data files unknown. The status check passes --untracked-files=normal, so status.showUntrackedFiles=no cannot hide untracked files. Only the coverage outputs at the root and under .data are regenerable.
The sync failure test wrote the relative default .code-workspace into the root of the worktree that ran the suite, and the scope rule counted it as data. The test now points workspace.file at tmp_path. The fake git of the prune tests answers ls-files as real git does, so a broken .git file fails it with 128.
The prune delta modifies 'Local state protects a worktree': the scope refusal comes before the lock and the dirty state, and the dirty count includes untracked files that the git configuration hides. New scenarios cover a data file written during the GitHub reads, a directory that git cannot open and a note named like coverage output. TESTING.md names the before_answer hook of the GitHub fake.
The default .code-workspace resolves in the project root. The sync test of test_repos.py and the clone tests of test_repos_sync_gitea.py wrote it into the worktree that ran the suite, and prune counted it as data. The test floor now writes workspace.file under tmp_path into the config of each test, so the change of the sync test is not needed.
a745746 to
bbaa733
Compare
🤖 I have created a release *beep* *boop* --- ## [0.182.3](v0.182.2...v0.182.3) (2026-11-20) ### Bug Fixes * **repos:** prune keeps worktrees with data or outside its folder ([#6477](#6477)) ([0fc3d13](0fc3d13)) --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please). Co-authored-by: dan-petty-release[bot] <346998822+dan-petty-release[bot]@users.noreply.github.com>
devops repos worktrees prune --confirmremoved each clean worktree at the head of a merged pull request in any folder, andgit worktree removealso deletes the files that.gitignorehides.Prune and the reclaim of
worktrees addnow ask one scope rule. It keeps a worktree outside.data/agent/worktrees, also a record whose directory looks missing, and a worktree that holds an ignored data file. Caches such as.venvand__pycache__are no data: used worktrees hold 70 to 165 ignored paths, nearly all caches. Prune asks the rule again right before each removal, and a warning ofgit ls-filesmakes the count unknown. The dirty check sees untracked files also whenstatus.showUntrackedFilesisno.--forcestill removes each worktree but the main one and the one of the current directory. Each test gets its own workspace file.Closes #6435
Change:
openspec/changes/archive/2026-11-20-6435-worktrees-prune-deletes-ignored-and-foreign/