codeowners
codeowners copied to clipboard
Double asterisk wildcard overreach?
hello! thanks for making this super useful library :)
In path_to_regex(), is it intended that the expanded ** regex match not only subfolders, but also partial filenames?
For example, a/**/b/ converts to re.compile('\\Aa/.*b/'), which will match paths like a/prefix_b/:
# expected ** behavior
>>> re.compile('\\Aa/.*b/').findall("a/b/")
['a/b/']
>>> re.compile('\\Aa/.*b/').findall("a/subfolder/b/")
['a/subfolder/b/']
# is this behavior also expected?
>>> re.compile('\\Aa/.*b/').findall("a/prefix_b/")
['a/prefix_b/']
This seems different from what git does; the docs say that codeowners follows mostly the same patterns as gitignore, which doesn't seem to recognize ** as prefixes:
# gitignore rule: a/**/b
# folder directory
>> ls -R a
a:
b prefix_b
# matches rule, is ignored
>> git check-ignore a/b -n -v
.gitignore:8:a/**/b a/b
# no matches
>> git check-ignore a/prefix_b -n -v
:: a/prefix_b
Thank you so much! Happy Halloween ^ ^