One function
fnmatch_pathname_to_regex in mherrmann/gitignore_parser
The author described this change as “Fix lack of implicit anchoring of patterns to directory separators”. It counts as a record because the check below fails on the code as it stood at 8ea444424 and passes on cdf80b7b1, with nothing else changed between the two runs.
Projectmherrmann/gitignore_parser
Fix saved2023-10-04
Sharing licenceMIT · LICENSE
Change size+3 −1
What the code was meant to do, written into the code itself as a docstring
Implements fnmatch style-behavior, as though with FNM_PATHNAME flagged; the path separator will not match shell-style '*' and '.' wildcards.
The change
| 55 | 55 | res.append(re.escape(c)) | |
| 56 | 56 | if anchored: | |
| 57 | 57 | res.insert(0, '^') | |
| 58 | + | else: | |
| 59 | + | res.insert(0, f"(^|{seps_group})") | |
| 58 | 60 | if not directory_only: | |
| 59 | 61 | res.append('$') | |
| 60 | 62 | elif directory_only and negation: | |
| 61 | 63 | res.append('/$') | |
| 62 | 64 | else: | |
| 63 | - | res.append('($|\/)') | |
| 65 | + | res.append('($|\\/)') | |
| 64 | 66 | return ''.join(res) |
The check that tells the two apart
fail→pass·tests.py::Test::test_incomplete_filename
Check file tests.py, taken without changes from the fix and copied onto the older code, so the exact same check runs against both versions.
Origin and history
The code before it8ea4444243e79aa6a359d58b9e9196c15ae6d2d8
Broken version dated2023-10-03
Modulegitignore_parser
Units changedfnmatch_pathname_to_regex
Fingerprint52d54b58932c2749
Checked2026-08-18 by goldset/0.1
Every field above is generated by our program. None of it is written by hand.
Other bugs found in mherrmann/gitignore_parser
- 2024-01-19Fix ValueError for some symlinks
- 2023-10-05Fix: do not resolve symlinks
- 2023-10-04rule_from_pattern
- 2023-10-03rule_from_pattern
- 2023-10-03fnmatch_pathname_to_regex
- 2023-06-30fnmatch_pathname_to_regex