One function
check_path_match in valohai/gitignorant
The author described this change as “Fix treating excludes without path as directories”. It counts as a record because the checks below fail on the code as it stood at bec0785ae and pass on 4ef503368, with nothing else changed between the two runs.
Projectvalohai/gitignorant
Fix saved2024-10-31
Sharing licenceMIT · LICENSE
Change size+1 −1
What the code was meant to do, written into the code itself as a docstring
Check whether the given path or its parent directories match any of the rules. In other words, * Split the path into directory and the filename (using `split_path`) * Split the directory into directory parts (using `os.sep`) * For each directory part from left to right, merge it with all previous directory parts and check that against all rules with `is_dir=True` * If a positive match is found, return `True` immediately * If no match or a negative match, keep iterating for a possible positive match deeper in the path * If loop finishes, finally check exact path match with `is_dir=False`. If no match, return `False`.
The change
| 20 | 20 | """ | |
| 21 | 21 | ||
| 22 | 22 | dirname, _ = split_path(path) | |
| 23 | - | dir_parts = dirname.split(os.sep) | |
| 23 | + | dir_parts = [part for part in dirname.split(os.sep) if part] | |
| 24 | 24 | path_to_match = "" | |
| 25 | 25 | ||
| 26 | 26 | for part in dir_parts: |
The check that tells the two apart
fail→pass·test_gitignorant.py::test_ignore_all_but_excluded[include_this-False]
fail→pass·test_gitignorant.py::test_ignore_all_but_excluded[include_with_wildcard-False]
Check file test_gitignorant.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 itbec0785aeda9790cc4abbef8d181e268195a370f
Broken version dated2023-08-23
Modulegitignorant.__init__
Units changedcheck_path_match
Fingerprinte7a3479a73545ef2
Checked2026-08-18 by goldset/0.1
Every field above is generated by our program. None of it is written by hand.