fix(rules): prevent flag negation from being consumed as preceding flag's value#191
fix(rules): prevent flag negation from being consumed as preceding flag's value#191
Conversation
…ag's value A flag negation like `!--in-place` following a bare flag like `--parse` was incorrectly parsed as the flag's value (FlagWithValue), causing the pattern `git interpret-trailers --parse !--in-place *` to never match any command. Treat negation tokens whose inner value is a flag as independent negation tokens rather than flag values in `should_consume_as_value`. Co-Authored-By: Claude Opus 4.6 <[email protected]>
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 addresses a critical parsing bug that caused command-line patterns with negated flags to be misinterpreted. By refining the token consumption logic, the system now accurately distinguishes negated flags from flag values, leading to more reliable rule matching and preventing unexpected failures in command evaluation. 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
|
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #191 +/- ##
==========================================
- Coverage 90.41% 90.29% -0.12%
==========================================
Files 40 40
Lines 7520 7522 +2
==========================================
- Hits 6799 6792 -7
- Misses 721 730 +9
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:
|
The comment said "no trailing arguments" but two of the three test cases do include trailing arguments. Simplify to match all cases.
The parser previously consumed `!--flag` as a preceding flag's value.
Add PBT to verify `{cmd} {literal} !{flag} *` patterns correctly
allow when the negated flag is absent and reject when present.
Why
--flag !--other-flagpatterns incorrectly consumed!--other-flagas the preceding flag's value instead of treating it as an independent negation tokengit interpret-trailers --parse !--in-place *failed to matchgit interpret-trailers --parseWhat
!--flag,!-f) as independent tokens rather than consuming them as flag values