Observed Behavior
When worktrees are created within subdirectories or with paths containing slashes (e.g. feature/login), PruneCommand._iter_worktrees extracts Path(wt["path"]).name, truncating the path to only its basename (login). When _do_prune subsequently invokes git.remove_worktree("login"), git fails because no worktree named login exists in the project root.
Expected Behavior
PruneCommand should resolve the relative path of the worktree directory relative to project_dir so that nested worktrees (e.g. feature/login) can be accurately located and removed by git worktree remove.
Steps to Reproduce
- Check out a worktree containing a slash in the branch/worktree name:
treefort checkout feature/my-feature (creates directory <project_dir>/feature/my-feature).
- Merge the corresponding PR on GitHub.
- Run
treefort prune --yes.
_iter_worktrees yields worktree_name = "my-feature" instead of "feature/my-feature".
git worktree remove -- my-feature fails with exit code 128: fatal: 'my-feature' is not a working tree.
Minimal Reproduction Environment / Conditions
- Version / Branch / Commit:
release-v0.5.x@6d07c0c
- Component:
treefort.commands.prune.PruneCommand
- Trigger: Any branch name containing slashes (e.g.,
feature/branch, bugfix/issue)
Errors, Logs & Telemetry
ERROR: Failed to prune 'my-feature': Command failed, with exit status 128: git worktree remove -- my-feature
fatal: 'my-feature' is not a working tree
Code location in src/treefort/commands/prune.py:72:
worktree_name = Path(wt["path"]).name # Truncates 'feature/my-feature' to 'my-feature'
Deliverables & Testing Requirements
- Preserve relative worktree subpaths by computing
Path(wt["path"]).resolve().relative_to(project_dir.resolve()).as_posix() rather than taking .name.
- Regression Safety: Add a unit test in
tests/commands/test_prune.py verifying that a worktree at subpath/feature is correctly identified and pruned with its full relative path.
Technical Pointers & Root Cause Clues
- Suspected Components:
src/treefort/commands/prune.py:72, 118
- Related Commits:
bd7ed4c (Add new prune command for removing worktrees for merged PR branches)
Notes & Edge Cases
- Branches containing slashes (
feature/*, fix/*) are standard git conventions and are explicitly supported by open_worktree in GitCLI.
Metadata
Severity / Priority: P0 (Blocker)
Area: bug, prune, git
AI Usage
Drafted with Gemini following the DEEP framework based on code review findings against release-v0.5.x. Reproduction conditions and code references were verified in the codebase.
Observed Behavior
When worktrees are created within subdirectories or with paths containing slashes (e.g.
feature/login),PruneCommand._iter_worktreesextractsPath(wt["path"]).name, truncating the path to only its basename (login). When_do_prunesubsequently invokesgit.remove_worktree("login"), git fails because no worktree namedloginexists in the project root.Expected Behavior
PruneCommandshould resolve the relative path of the worktree directory relative toproject_dirso that nested worktrees (e.g.feature/login) can be accurately located and removed bygit worktree remove.Steps to Reproduce
treefort checkout feature/my-feature(creates directory<project_dir>/feature/my-feature).treefort prune --yes._iter_worktreesyieldsworktree_name = "my-feature"instead of"feature/my-feature".git worktree remove -- my-featurefails with exit code 128:fatal: 'my-feature' is not a working tree.Minimal Reproduction Environment / Conditions
release-v0.5.x@6d07c0ctreefort.commands.prune.PruneCommandfeature/branch,bugfix/issue)Errors, Logs & Telemetry
Code location in
src/treefort/commands/prune.py:72:Deliverables & Testing Requirements
Path(wt["path"]).resolve().relative_to(project_dir.resolve()).as_posix()rather than taking.name.tests/commands/test_prune.pyverifying that a worktree atsubpath/featureis correctly identified and pruned with its full relative path.Technical Pointers & Root Cause Clues
src/treefort/commands/prune.py:72, 118bd7ed4c(Add new prune command for removing worktrees for merged PR branches)Notes & Edge Cases
feature/*,fix/*) are standard git conventions and are explicitly supported byopen_worktreeinGitCLI.Metadata
Severity / Priority: P0 (Blocker)
Area:
bug,prune,gitAI Usage
Drafted with Gemini following the DEEP framework based on code review findings against
release-v0.5.x. Reproduction conditions and code references were verified in the codebase.