fix: ignore invalid gitignore bracket ranges#123
Open
Gares95 wants to merge 1 commit into
Open
Conversation
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.
Summary
This updates
GitIgnoreSpecPatternso reversed invalid bracket ranges such as[z-a]anda[z-a]are treated as null patterns instead of propagating a regex compile error.This matches the existing invalid-range handling direction for gitignore spec patterns and keeps
GitIgnoreBasicPatternbehavior unchanged.What changed
range_error == "raise"path._RangeErrorflow.[z-a]anda[z-a]produce null patterns:include is Noneregex is NoneWhy
The surrounding test already notes that these patterns should become null patterns to fully replicate Git behavior. This makes reversed invalid ranges consistent with the existing invalid-range cases already covered by the test suite.
Tests
Ran:
python -m unittest tests.test_04_gitignore_spec.GitIgnoreSpecPatternTest.test_15_issue_93_c_2_invalid python -m unittest tests.test_04_gitignore_spec python -m unittest tests.test_03_gitignore_basic python -m unittest tests.test_06_gitignore python -m unittest discover -t . -s tests/Full configured unittest result:
Compatibility notes
GitIgnoreSpecPattern.GitIgnoreBasicPatternbehavior is unchanged.