Repository navigation
feat: wt delete takes more than one worktree - #9
Merged
Merged
Conversation
wt delete took one worktree. Remove several worktrees in one command: `wt d a b c`. The command finds each name before it removes anything, so a name that is wrong changes nothing. Git can refuse a worktree that has a modified or untracked file. The command then keeps that worktree, removes the others and fails at the end with the names that it kept. A worktree that has two names in the list, its directory and its path, is removed one time.
The error for a wrong name gave only the first one, so a list with two typos took two runs to correct. It now gives each wrong name. The message for a refusal said "use --force to remove it" also for two worktrees, and also when --force was on. It now says "them" for more than one worktree. With --force it gives no hint, because git refused for a different reason, for example a lock. Three tests run the command in a temporary repository: a wrong name changes nothing, a worktree with two names in the list is removed one time, and a refusal keeps that worktree and removes the others. The git helper for the fixtures moves from the tests of `wt add` to src/testing.rs, so the two modules share it.
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.
wt deletetook one worktree. It now takes several:wt d a b c.--forceapplies to each worktree.--forceit gives no hint, because git refused for a different reason, for example a lock.The fish completion already offers the worktrees for each argument after
wt d. Only its description changes.The git helper for the test fixtures moves from the tests of
wt addtosrc/testing.rs, so the tests ofwt addandwt deleteshare it.Test
Format check, clippy and
cargo testpass. Three new tests runwt deletein a temporary repository:Each test fails when the behavior that it protects is removed from the code.
A manual test in a temporary repository with the worktrees
a b c dand an untracked file inc:wt d a typo bwt d typo a othertypoandother. Nothing removed.wt d a b c aaandbremoved.ckept, exit 1.wt d c d --forcecanddremoved.wt dWith a locked worktree
l,wt d l d --forceremovesd, keepsland fails withwt cannot remove l, with no hint to use--force.