Let wt prune remove dirty merged worktrees with --force - #51
Merged
Conversation
Prune tried `git worktree remove` without --force on every merged candidate, so a merged worktree with uncommitted changes failed with a warning after the user had already confirmed and after teardown hooks had run. Prune now checks each merged candidate for uncommitted changes up front and shows a STATUS column (clean/dirty). Dirty worktrees are kept unless --force is given, and are skipped before teardown hooks run. The confirmation count only includes worktrees that will actually be removed. --force changes meaning to match `wt remove --force`: it removes merged worktrees even when they have uncommitted changes, and is forwarded to git so worktrees git considers unclean for other reasons (submodules) are removed too. A new --yes flag takes over skipping the confirmation prompt. Help text, README, and the agents guide are updated accordingly. Claude-Session: https://claude.ai/code/session_01VrT5beDfJZ5EwsN3RDCCS3
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.
Summary
wt prunenow checks each merged candidate for uncommitted changes and shows aSTATUScolumn (clean/dirty).--forceis given, and are skipped before teardown hooks run. The confirmation prompt counts only what will actually be removed.--forcenow means "remove merged worktrees even if they have uncommitted changes", matchingwt remove --force. It is forwarded togit worktree removeso worktrees git considers unclean for other reasons (e.g. submodules) are removed too.--yesflag skips the confirmation prompt. Scripts usingwt prune --forcefor non-interactive runs should switch to--yes.--help, README, and thewt agentsguide document the new flags.Previously prune ran
git worktree removewithout--force, so a dirty merged worktree failed with a warning after confirmation and after teardown hooks had already run.Test plan
make dev(gofumpt, golangci-lint,go test ./..., build) passesTestPartitionPrunable,TestPrunableStatuse2e/testdata/prune.txtar: dirty merged worktree kept without--force,Nothing to pruneon rerun,--dry-run --forceleaves it,--force --yesremoves itwt prunein a project with a dirty merged worktree shows the table, the kept-count warning, and the prompthttps://claude.ai/code/session_01VrT5beDfJZ5EwsN3RDCCS3