Skip to content

Let pair prune take name patterns - #66

Merged
leonlee merged 1 commit into
mainfrom
feature/prune-patterns
Nov 20, 2026
Merged

leonlee merged 1 commit into
mainfrom
feature/prune-patterns

Conversation

@leonlee

@leonlee leonlee commented Nov 20, 2026

Copy link
Copy Markdown
Owner

Summary

  • pair prune [PATTERN...] [--dry-run] [--yes]: with patterns, prune covers only channels whose name matches one, so you can delete some removed worktrees' history and keep the rest (e.g. pair prune 'acq-mono-at-18*').
  • Shell-style patterns: * any run of characters, ? any one, everything else literal. They only narrow the existing list; channels prune can't place are never selected. No match prints no channel matches '…'.
  • The matcher works on code points (? takes a whole emoji) and backtracks only to the last *, so matching time stays bounded by pattern × name length.
  • Help, usage, README, README.zh-CN and the Unreleased CHANGELOG entry updated.

Review

Reviewed by codex over two rounds: round 1 found ? matching UTF-16 code units and exponential backtracking with multiple * in the first regex-based version; both fixed with a dedicated matcher and regression tests, approved in round 2 (codex also cross-checked the matcher against an independent DP matcher on 1.1M pattern/name pairs).

Test plan

  • npm run build, git diff --check
  • npm test: 232 passed
  • Mutation check: the pattern test fails with the old regex matcher
  • node dist/pair.js prune 'acq-mono-at-18*' --dry-run on a real ~/.pair: 19 listed, nothing deleted
  • Linux

🤖 Generated with Claude Code

https://claude.ai/code/session_012Y3kg5hjT2zSZM9qUEEinM

pair prune [PATTERN...] covers only the channels whose name matches a
pattern, so a user can delete some removed worktrees' history and keep
the rest. Patterns are shell-style: * any run of characters, ? any one,
everything else literal. They only narrow the list; a channel prune
can't place is never selected. No match prints the patterns.

The matcher works on code points, so ? takes a whole emoji, and
backtracks only to the last star, so its time stays bounded by
pattern length times name length.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012Y3kg5hjT2zSZM9qUEEinM
@leonlee
leonlee merged commit 55c53ab into main Nov 20, 2026
3 checks passed
@leonlee
leonlee deleted the feature/prune-patterns branch November 20, 2026 05:33
@leonlee leonlee mentioned this pull request Nov 20, 2026
3 tasks done
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