Skip to content

Commit 5e791d0

Browse files
committed
Fix failing cr check for year 2026
Signed-off-by: Philipp Ahmann <Philipp.Ahmann@de.bosch.com>
1 parent fe54d6a commit 5e791d0

1 file changed

Lines changed: 27 additions & 11 deletions

File tree

cr_checker/tool/cr_checker.py

Lines changed: 27 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -124,17 +124,33 @@ def get_author_from_config(config_path: Path = None) -> str:
124124

125125
def convert_bre_to_regex(template: str) -> str:
126126
"""
127-
Convert BRE-style template (literal by default) to standard regex.
128-
In the template: * is literal, \\* is a metacharacter.
127+
Convert a BRE-like template into a regex:
128+
- '\' escapes one character into a regex meta character
129+
- '*' is literal unless escaped as '\*' (implicitly covered)
130+
- everything else is taken literally
129131
"""
130-
# First, escape all regex metacharacters to make them literal
131-
escaped = re.escape(template)
132-
# Now, find escaped backslashes followed by escaped metacharacters
133-
# and convert them back to actual regex metacharacters
134-
metacharacters = r"\\.*+-?[]{}()^$|"
135-
for char in metacharacters:
136-
escaped = escaped.replace(re.escape("\\" + char), char)
137-
return escaped
132+
133+
out = []
134+
i = 0
135+
L = len(template)
136+
137+
while i < L:
138+
ch = template[i]
139+
140+
# Escape sequences
141+
if ch == "\\" and i + 1 < L:
142+
nxt = template[i + 1]
143+
144+
# Next char becomes regex meta character
145+
out.append(nxt)
146+
i += 2
147+
continue
148+
149+
# Literal characters → re.escape
150+
out.append(re.escape(ch))
151+
i += 1
152+
153+
return "".join(out)
138154

139155

140156
def load_templates(path):
@@ -194,7 +210,7 @@ def load_exclusion(path):
194210
path (str): Path to the exclusion file.
195211
196212
Returns:
197-
tuple(list, bool): a list of files that are excluded from the coypright check and a boolean indicating whether
213+
tuple(list, bool): a list of files that are excluded from the copyright check and a boolean indicating whether
198214
all paths listed in the exclusion file exist and are files.
199215
"""
200216

0 commit comments

Comments
 (0)