feat!: treat * inside quotes as glob, support \* escape for literal asterisk#157
feat!: treat * inside quotes as glob, support \* escape for literal asterisk#157
* inside quotes as glob, support \* escape for literal asterisk#157Conversation
…terisk Quoted strings (`'...'` / `"..."`) previously suppressed glob expansion via the `QuotedLiteral` token type, making `*` inside quotes match only the literal asterisk character. This prevented patterns like `'renovate-config-validator *'` from matching arbitrary file arguments. Change quotes to act as grouping only (preserving spaces in a single token) while allowing `*` to work as a glob wildcard. Users who need a literal `*` can now escape it with `\*`, consistent with gitignore and editorconfig conventions. - Remove `LexToken::QuotedLiteral` and `PatternToken::QuotedLiteral` - Add backslash escape support in lexer (`consume_until`, `consume_word`) - Update matcher (`literal_matches`, `glob_match`) to handle `\*` as literal asterisk via `has_unescaped_glob`, `unescape`, `split_on_unescaped_glob` helpers Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request significantly enhances the pattern matching capabilities by reinterpreting how wildcards behave within quoted strings. Previously, Highlights
Changelog
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
…glob # Conflicts: # src/rules/pattern_matcher.rs # tests/integration/config_to_rule_evaluation.rs
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #157 +/- ##
==========================================
+ Coverage 89.81% 89.82% +0.01%
==========================================
Files 50 50
Lines 10325 10345 +20
==========================================
+ Hits 9273 9292 +19
- Misses 1052 1053 +1
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Remove redundant `\*` escape example from "Quotes and Glob" section that duplicated the example already shown in "Escaping `*` with Backslash". Consolidate `quoted_star_acts_as_glob` and `escaped_star_is_literal` integration tests into a single parameterized `quoted_and_escaped_star_matching` test per the repository's rstest style guide. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
formatdoc! is more concise and idiomatic for inline string interpolation with indoc-style formatting. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Merge origin/main into the quoted-literal-glob branch, resolving conflicts in the restructured pattern_matcher module (now split into mod.rs, token_matching.rs, flag_utils.rs) and updated integration tests. Remove QuotedLiteral from the new submodules and update property-based tests to reflect the new semantics (quotes are grouping only, `*` acts as glob, `\*` for literal).
…dling Two bugs found by Devin review: 1. Merging QuotedLiteral into Literal caused should_consume_as_value to reject quoted flag-like values (e.g., "-v" in `grep -e "-v" *`), preventing them from being consumed as flag values. Restore LexToken::QuotedLiteral so the parser can distinguish quoted tokens from bare literals for flag-value association, while still converting them to PatternToken::Literal (glob-enabled) for matching. 2. consume_until treated `\` + closing delimiter as an escape sequence, eating the closing quote and causing "unclosed quote" errors for patterns like `cmd 'hello\\'`. Fix by not escaping when the next character is the closing delimiter.
…ackslash The backslash handler in consume_word unconditionally consumed the next character, even when it was a word-boundary character (space, tab, brackets, quotes). This caused patterns containing a backslash followed by a space-delimited token to be tokenized as a single word instead of two separate tokens. Also fix unescape_and_match to preserve trailing backslashes as literal instead of silently dropping them, and correct the test command in backslash_before_closing_quote to use a shell-escaped backslash.
Why
*inside quotes ('...'/"...") is treated asQuotedLiteral(exact match only), not as a glob wildcardnpx -c 'renovate-config-validator *'does not match inputs likerenovate-config-validator foo.jsonbecause*is not expanded as a globWhat
*inside quotes to act as a glob wildcard, and introduce\*escape syntax for matching a literal*characterLexToken::QuotedLiteralandPatternToken::QuotedLiteral, unifying them intoLiteral