fix(remove): suppress remote-delete prompt for --yes/--non-interactive/--dry-run#21
Merged
Merged
Conversation
…e/--dry-run
Running `wt remove <branch> --delete-branch --yes` still prompted "Also
delete remote branch?" because resolveDeleteRemoteBranch only short-
circuited on ui.nonInteractive. That blocks agent/CI callers. --dry-run
had the same problem: the prompt fired before the plan was printed.
Resolution rule (now documented at the resolvers and in CLI help):
1. explicit --delete-branch / --delete-remote-branch wins
2. config value (remove.deleteBranch / remove.deleteRemoteBranch)
3. --yes, global --non-interactive, or --dry-run → default to false
(destructive defaults must require explicit opt-in)
4. otherwise prompt
Applied symmetrically to resolveDeleteBranch — same non-interactive
contract for the local-branch prompt.
Closes Vikunja #49 (id 311).
Review of PR #21 (Vikunja #49) flagged two follow-ups: 1. Test gap: all four new tests in the non-interactive describe block passed `delete-branch: true`, so resolution short-circuited at step 1 (explicit flag wins) and the new yes-gate in `resolveDeleteBranch` was never exercised. Added three cases: - `--yes` alone (no flag, no config) → no prompt, no branch delete - `--yes` with explicit `--delete-remote-branch=false` (opt-out beats yes-gate) - `--yes` with config `remove.deleteRemoteBranch=true` (config beats yes-gate) 2. Help-text drift: the three new `--help` strings stuffed the same `--yes/--non-interactive/--dry-run` triplet into every flag, breaking the codebase's short-imperative style. Hoisted the caveat once into the `--yes` description and reverted `--delete-branch` / `--delete-remote-branch` to their original one-liners. Also tweaked the resolution-order comment: bullet 3 said "default to false" but the resolvers actually return false AND skip the prompt; reworded to match.
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.
What
wt remove <branch> --delete-branch --force --yesstill prompted "Also delete remote branch?" interactively, blocking agent/CI callers.--dry-runhad the same problem: the prompt fired before the plan was printed, so dry-run wasn't fully non-interactive either.Why
resolveDeleteRemoteBranchonly short-circuited onui.nonInteractive.--yesand--dry-runweren't honored, so any caller that hadn't also set the global--non-interactiveflag (or didn't pass--delete-remote-branchexplicitly) would hang on the confirm prompt.Fix — resolution rule
Documented at the resolvers in
src/cli/resolve-params.tsand in the CLI help text:--delete-branch/--delete-remote-branchflag wins.remove.deleteBranch/remove.deleteRemoteBranch) is consulted next.--yes, global--non-interactive, or--dry-run— default tofalse. Destructive defaults require explicit opt-in, so agents/CI never accidentally delete branches or remote refs.Applied symmetrically to
resolveDeleteBranchso the local-branch prompt follows the same contract. The dry-run plan now reflects the resolved (non-interactive) decision — e.g.Would delete branch "feature" (local)instead of asking first.Tests
Extended
src/cli/commands/remove.test.tswith the non-interactive path coverage:--yeswith--delete-branch(no--delete-remote-branch) → noconfirmcall, remote not touched.--non-interactivewith--delete-branch→ noconfirmcall, remote not touched.--dry-runwith--delete-branch→ noconfirmcall, plan reads "(local)" only.--yeswith explicit--delete-remote-branch→ noconfirmcall, remote IS deleted (opt-in respected).Checks
pnpm typecheck— greenpnpm lint— greenpnpm test— 497 pass / 0 failReference
Closes Vikunja #49 (id 311).