Repository navigation
Conversation
…terns
expandBraces cut a pattern at its first '{' and first '}', so nested groups
such as **/*.{ts,{js,jsx}} stopped matching .ts and .jsx files and escaped
braces were split as a group. doublestar already reads both correctly, so
rules, include and exclude now hand it the whole pattern.
Contributor
|
🔍 OpenCodeReview found 1 issue(s) in this PR.
📄
|
This branch has not been deployed
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.
Description
expandBracessplit a pattern at its first{and its first}before matching. It servedrules,includeandexcludeinrule.jsonand the built-inpath_rule_map, and broke two kinds of patterns:**/*.{ts,{js,jsx}}became*.ts},*.{js}and*.jsx}, so only.jsmatched;pages/\{id\}.tswas split as a group and never matched the literalpages/{id}.ts.doublestar already expands brace groups, including nested groups and backslash escapes, so
IsUserIncluded,IsUserExcluded,matchProjectRuleEntryandSystemRule.resolveDetailnow hand it the whole lowercased pattern through onematchGlobhelper. Patterns with a single group match exactly as before, andRuleDetail.Patternstill reports the original pattern.expandBracesmoves to the test file: only the system-rule integrity check that reads each arm's extension still needs it. The validity check now validates the whole pattern withdoublestar.ValidatePattern, since that is what matching uses.I first tried a full recursive expansion instead. It would also have rewritten braces inside
[...]classes and built every combination of several groups for each path checked, so handing the pattern to doublestar is both simpler and exact.Type of Change
How Has This Been Tested?
make testpasses locallyManual testing (describe below)
New
TestBracePatternsMatchLikeDoublestarchecks nested groups, a nested group in a suffix, two groups, escaped literal braces and an unclosed group against all four matchers, and first asserts each expectation againstdoublestar.Matchitself. On the previousexpandBraces6 of its 10 cases fail (the nested and escaped ones); with this change all pass.LC_ALL=C go test ./internal/config/rules/...: 534 passed.gofmt -s -landgo vetare clean.ocr review --audience agenton the change: 0 findings.Checklist
go fmt,go vet)Used Claude Code (Claude Opus 5.5).
Related Issues
Closes #2097