Skip to content

feat: wt delete takes more than one worktree - #6

Open
lorenzolfm wants to merge 1 commit into
mainfrom
delete-multiple-at-once
Open

lorenzolfm wants to merge 1 commit into
mainfrom
delete-multiple-at-once

Conversation

@lorenzolfm

Copy link
Copy Markdown
Owner

wt delete eng-1234 eng-5678 removes both. Two reviews land in the same afternoon, and the tool asked for wt delete twice.

The rules

  • Every name is read first. A name that is not a worktree stops the command with the list of names, and nothing is removed. A list is typed in one line and read back in one glance, so a typo in the second name is a list you did not mean to run.
  • A repetition is one worktree. A name and the path of the same worktree name one worktree; the second git worktree remove of it would fail with a reason that says nothing.
  • A refusal does not stop the list. Git prints its own reason, wt collects the name, and the command fails at the end naming each one, so the exit code still says the list did not run in full.
  • The count prints for a list only. One name gives one line, and that line is the whole report. Output for a single worktree is unchanged.

Notes

resolve takes the worktrees and the names and returns the choice, so order, repetition and the unknown name are unit tests that need no repository. The fish completions need no change: they already offer a worktree name after delete and d, at each position.

Verified

In a scratch repository: an unknown name removes nothing (exit 1); two clean worktrees go together; a dirty worktree is kept while its clean neighbour is removed, with both reported (exit 1); wt delete with no argument is a clap usage error. cargo clippy --all-targets -- -D warnings is clean, 38 tests pass.

A branch is rarely finished alone. Two reviews land in the same afternoon,
and the tool asked for `wt delete` twice, each with its own git invocation
and its own report. `wt delete eng-1234 eng-5678` removes both.

The command reads every name before it removes anything. A name that is not
a worktree stops it with the list of names, as it did before, and no
worktree is gone by then. A list is something you type in one line and read
back in one glance, so a typo in the second name is a list you did not mean
to run; a partial removal would leave you to work out which half happened.
The same read folds a repetition: a name and the path of the same worktree
name one worktree, and the second `git worktree remove` of it would fail
with a reason that says nothing about what you typed.

A worktree that git refuses no longer stops the ones behind it. Git prints
its own reason, wt collects the name, and the command reports each refusal
in the message it fails with, so the exit code still says that the list did
not run in full.

The count at the end prints for a list only. One name gives one line, and
that line is already the whole report; a list needs the count, because git
writes its refusals between the lines of wt.

`resolve` takes the worktrees and the names and returns the choice, so the
order, the repetition and the unknown name are tests that need no
repository.

The fish completions need no change. They offer a worktree name after
`delete` and after `d`, and fish offers them again at each position.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant