Repository navigation
Description
Problem
Checked at main (0fb04e1).
CONST_WORKTREE_REGENERABLE_PATHSPECS(src/devops_cli/config/constants.py:796-816) excludes.venv,dist,buildandhtmlcovonly at the root of a worktree (:(exclude).venv). The cache directories__pycache__,.pytest_cache,.ruff_cache,.mypy_cache,.hypothesisandnode_modulesuse:(exclude,glob)**/<name>/**, so they match at any depth.- A service repository can keep its uv project in a subdirectory, for example
services/<name>/pyproject.toml. Thenuv run --directory services/<name>makesservices/<name>/.venv.count_ignored_data_files(src/devops_cli/git/worktree_inventory.py:243) counts each file of that.venvas data. - Result, 2026-11-21: in a service repository with such a project,
devops repos worktrees prune --repo-dir <clone>refused all 9 worktrees of merged pull requests with "holds 1358 ignored data files".git ls-files --others --ignored --exclude-standardin one of them listed onlyservices/<name>/.venv,__pycache__,.pytest_cacheand.ruff_cache. The prune removed nothing, andworktrees add --reclaimkeeps the same worktrees.
Proposed remedy
- Change the
.venvpathspec to:(exclude,glob)**/.venv/**, so that a virtual environment at any depth is a cache, as__pycache__already is. - Keep
dist,buildandhtmlcovat the root only, unless a test shows the same need: a nestedbuilddirectory can hold files that are not a cache.
Acceptance criteria
- A test makes a worktree whose only ignored files are in
sub/project/.venv, andcount_ignored_data_filesreturns 0. - A test makes a worktree with an ignored file in
.data/agent/and one insub/project/.venv, and the count is 1. -
devops repos worktrees prunepreviews a merged worktree that holds only a nested.venvas removable.
Alternatives check of 2026-11-21: none.
Tool: none found.
Reason: Searches returned only unrelated MDN pages; no maintained tool counts non-regenerable ignored files in a git worktree. The remedy is a one-line change to the project's own pathspec constant, which git already supports.
Proposed design
Problem statement
devops repos worktrees prune counts each file of a nested virtual environment as ignored data. A service repository that keeps its uv project in services/<name> gets services/<name>/.venv. Prune then refuses each such worktree with a high count, and the reclaim of worktrees add keeps the same worktrees. The fix excludes a .venv directory at any depth, as the cache directories already are.
Acceptance criteria
Requirement: Nested virtual environment is a cache
The count of ignored data files SHALL exclude the contents of a .venv directory at any depth of a worktree.
Scenario: A worktree holds only a nested virtual environment
- WHEN A test makes a worktree whose ignored files are only under
sub/project/.venvand callscount_ignored_data_files. - THEN The call returns 0.
Requirement: Data file beside a nested virtual environment
The count of ignored data files SHALL include each ignored file that is not under a regenerable path.
Scenario: A data file beside a nested virtual environment
- WHEN A test makes a worktree with an ignored file in
.data/agent/and an ignored file insub/project/.venvand callscount_ignored_data_files. - THEN The call returns 1.
Requirement: Nested build directory is data
The count of ignored data files MUST include the contents of a build directory below the root of a worktree.
Scenario: A nested build directory
- WHEN A test makes a worktree with an ignored file in
sub/project/build/and callscount_ignored_data_files. - THEN The call returns 1.
Requirement: Prune preview of a nested virtual environment
devops repos worktrees prune SHALL mark a merged worktree whose only ignored files are under a nested .venv as removable.
Scenario: Prune previews a worktree with a nested virtual environment
- WHEN A test runs
devops repos worktrees prune --repo-dir <clone>with no--confirmagainst a clone whose merged worktree holds ignored files only undersub/project/.venv. - THEN The preview lists that worktree as removable and the command removes no worktree.
Existing Tool Considered
No open, maintained tool covers the need. The block Alternatives check of 2026-11-21: none in the issue body records the verdict none and no tool. The change uses the pathspec magic of git, which the project already uses at src/devops_cli/config/constants.py:797. Written cost of the own code: about 2,000 tokens to write the pathspec entry and four tests, about 5,000 tokens to keep and fix them for one year, and less than one hour of elapsed time.
Key questions
- Which code counts the ignored data files of a worktree, and which pathspecs does it use?:
count_ignored_data_filesatsrc/devops_cli/git/worktree_inventory.py:243runsgit ls-files --others --ignored --exclude-standardwithCONST_WORKTREE_REGENERABLE_PATHSPECSat line 271. The constant is atsrc/devops_cli/config/constants.py:797. [sources: src/devops_cli/git/worktree_inventory.py:243, src/devops_cli/git/worktree_inventory.py:271, src/devops_cli/config/constants.py:797] - Which form excludes a virtual environment at any depth?: Add
:(exclude,glob)**/.venv/**toCONST_WORKTREE_REGENERABLE_PATHSPECSand keep:(exclude).venvfor the root. This is the form that the cache entries already use. (best practice) [sources: src/devops_cli/config/constants.py:797, src/devops_cli/git/worktree_inventory.py:271]- Chosen: Add a glob entry at any depth and keep the root entry. The root entry keeps the current behavior at the root. The glob entry adds each deeper path, as the cache entries already do.
- Rejected: Replace the root entry with the glob entry. The spec lists
.venvat the root, and no test proves the glob form of the root case. - Rejected: Filter the paths in Python after
git ls-files. It adds code that the pathspec of git gives, and it splits the rule across two places.
- Which paths stay at the root only?: Keep
dist,buildandhtmlcovat the root only. The change adds no glob entry for them. (best practice) [sources: src/devops_cli/config/constants.py:797, openspec/specs/repos-worktrees-prune/spec.md:134]- Chosen: Keep
dist,buildandhtmlcovat the root only. A nestedbuilddirectory can hold files that are not a cache. A test must show the need before a wider exclude. - Rejected: Exclude
dist,buildandhtmlcovat any depth. No test shows the need, and a wider exclude hides data files.
- Chosen: Keep
- Which documents and tests state the regenerable path list?:
openspec/specs/repos-worktrees-prune/spec.md:134states the list, and its scenario at:111uses a root.venv. The scenario atopenspec/specs/repos-worktrees-add/spec.md:173uses caches at any depth.CONTRIBUTING.md:225names the list in prose.tests/git/test_repos_worktrees_reclaim_scope.pyholds the tests of the paths. The change updates the two spec files. [sources: openspec/specs/repos-worktrees-prune/spec.md:134, openspec/specs/repos-worktrees-prune/spec.md:111, openspec/specs/repos-worktrees-add/spec.md:173, CONTRIBUTING.md:225, tests/git/test_repos_worktrees_reclaim_scope.py]
Fit
Fits in one pull request.
Suspected block
None.
Dependencies
None.
Activity
dan-petty commentedon Nov 21, 2026
Both target the same count_ignored_data_files logic in worktrees prune, but #6435 stopped over-deletion while this stops under-deletion caused by a root-only .venv pathspec.devops-cli-service commentedon Nov 21, 2026
The result in the alternatives block of the issue body changed. Before this check: no check. A person decides what the new result means for the item.
Searches (7)
Searches run:
Sources:
devops-cli-service commentedon Nov 22, 2026
Next step: the stage job writes the plan of the item. See the section Proposed design of the body.
chore(main): release 0.218.2 (#7130)
devops-cli-service commentedon Nov 25, 2026
Released in v0.218.2: https://github.com/dan-petty/devops-cli/releases/tag/v0.218.2
devops-cli-service commentedon Nov 25, 2026
Live since 2026-11-25 08:43 UTC