One more fix for reviewer assignment (#36829)

* one more fix

* one more fix

* Trigger tests
This commit is contained in:
Matt
2025-03-19 16:25:24 +00:00
committed by GitHub
parent 7c233980f4
commit 63c3116530

View File

@@ -22,12 +22,16 @@ from collections import Counter
from pathlib import Path
def pattern_to_regex(pattern):
start_anchor = pattern.startswith("/")
pattern = re.escape(pattern)
if pattern.startswith("/"):
start_anchor = True
pattern = re.escape(pattern[1:])
else:
start_anchor = False
pattern = re.escape(pattern)
# Replace `*` with "any number of non-slash characters"
pattern = pattern.replace(r"\*", "[^/]*")
if start_anchor:
pattern = "^" + pattern
pattern = r"^\/?" + pattern # Allow an optional leading slash after the start of the string
return pattern
def get_file_owners(file_path, codeowners_lines):