fix(compat): slash-free grep/glob filters match by basename at any depth (#178)#200
Merged
Conversation
…pth (#178) globToRegExp anchored every pattern to the whole relative path (^...$), so a slash-free filter like glob:'*.ts' compiled to ^[^/]*\.ts$ and matched ROOT-LEVEL files only — every nested file was silently dropped. ripgrep (the semantics this tool advertises) matches slash-free globs against the basename at any depth, and that is the shape models emit most often. - A pattern with no '/' is prefixed with (?:^|.*/) (the same unanchored form gitignore.ts already uses), so '*.ts' matches root.ts AND src/nested.ts. A pattern containing '/' ('src/*.ts', '**/*.ts') keeps full-path anchoring, so '*' still never crosses a directory boundary. Shared globToRegExp → grep and glob stay consistent. - Document the behavior on the grep 'glob' field (slash-free = basename at any depth; slashed = whole worktree-relative path). Tests: slash-free matches nested (grep + glob tool), slashed stays anchored, the prior root-only assertion is corrected to the ripgrep behavior. Part of #196.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughThe search tools now match slash-free globs against basenames at any directory depth, while slash-containing globs remain anchored to relative paths. The glob schema documents these semantics, and tests cover both ChangesGlob matching semantics
Estimated code review effort: 2 (Simple) | ~10 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
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.
Closes #178. XS P1 batch from the parity verification (#196).
Problem
globToRegExpanchored every pattern to the whole relative path (^…$), so a slash-free filter likeglob: '*.ts'compiled to^[^/]*\.ts$and matched root-level files only — every nested file was silently dropped. ripgrep (the semantics this tool advertises) matches slash-free globs against the basename at any depth, and that is the shape models emit most often. Probe-verified:{pattern:'needle', glob:'*.ts'}overroot.ts+src/nested.tsreturned onlyroot.ts.Fix
A pattern with no
/is prefixed with(?:^|.*/)(the same unanchored formgitignore.tsalready uses), so*.tsmatchesroot.tsANDsrc/nested.ts. A pattern containing/(src/*.ts,**/*.ts) keeps full-path anchoring —*still never crosses a directory boundary. SharedglobToRegExp→ grep and glob stay consistent. The grepglobfield now documents the behavior.Tests
test:node(compat 255) + biome.Part of #196.
Summary by CodeRabbit
New Features
*.ts, which now match files in nested directories.src/*.ts.Bug Fixes