wt: Add test coverage for removal protection feature

Resolved 💬 2 comments Opened Jan 28, 2026 by ori-shalom Closed Mar 1, 2026

Context

The worktree removal protection feature added in the PR for wt rm safety checks currently lacks test coverage.

Suggested Test Cases

  1. getWorktreeStatus() returns correct counts for various git states:
  • Untracked files detection
  • Staged file count
  • Unstaged file count
  • Ahead count with upstream
  • Null ahead count when no upstream
  1. hasStatusIssues() correctly identifies when warnings are needed:
  • Returns true for untracked files
  • Returns true for staged changes
  • Returns true for unstaged changes
  • Returns true for unpushed commits
  • Returns true for no upstream (never pushed)
  • Returns false for clean worktree
  1. removeCommand() integration:
  • Non-TTY mode throws CliError when status issues exist without --force
  • --force flag bypasses all checks
  • Clean worktree proceeds without prompting

Files

  • packages/wt/src/init/detect.ts - getWorktreeStatus()
  • packages/wt/src/commands/remove.ts - hasStatusIssues(), printWorktreeWarnings(), removal flow

Priority

Medium - This is a safety-critical feature that prevents data loss.

View original on GitHub ↗

This issue has 2 comments on GitHub. Read the full discussion on GitHub ↗