Kill the surviving glob and breach-directory mutants of item 370

This commit is contained in:
2026-11-13 22:43:09 +01:00
parent 3213971f98
commit 637a60a017
2 changed files with 10 additions and 4 deletions
+1 -4
View File
@@ -121,10 +121,7 @@ def globbed(glob: str, searched: str, path: pathlib.Path) -> bool:
return False
if UNMATCHED.search(glob):
return True
if glob.startswith("!"):
# It only excludes files.
return False
anchored = glob.lstrip("/") if "/" in glob else f"**/{glob}"
anchored = glob.removeprefix("/") if "/" in glob else f"**/{glob}"
# A `**` that is not a whole folder name matches as `*` in ripgrep; crossing folders there only refuses more.
translated = {"**/": "(?:.*/)?", "**": ".*", "*": "[^/]*", "?": "[^/]"}
pattern = "".join(translated.get(piece, re.escape(piece)) for piece in re.split(r"(\*\*/|\*\*|\*|\?)", anchored))