Skip to content

Commit 7a6c0a3

Browse files
authored
fix(ci): License check on yml files (#26511)
1 parent fbb87ea commit 7a6c0a3

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

presto-native-execution/scripts/license-header.py

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -109,10 +109,6 @@ def wrapper_hash(header, args):
109109
}
110110
)
111111

112-
file_pattern = regex.compile(
113-
"|".join(["^" + fnmatch.translate(type) + "$" for type in file_types.keys()])
114-
)
115-
116112

117113
def get_filename(filename):
118114
return os.path.basename(filename)
@@ -155,14 +151,25 @@ def main():
155151

156152
header_text = file_lines(args.header)
157153

154+
# fnmatch.translate can generate "\z" in the regex pattern
155+
# which causes an error when compiled by regex:
156+
# regex._regex_core.error: bad escape \z at position 23
157+
# Usually, the pattern is generated with "\Z" which works fine.
158+
raw_pattern = "|".join(
159+
["^" + fnmatch.translate(type) + "$" for type in file_types.keys()]
160+
)
161+
pattern = raw_pattern.replace(r"\z", "\\Z")
162+
message(log_to, "File pattern : " + pattern)
163+
file_pattern = regex.compile(pattern)
164+
158165
if len(args.files) == 1 and args.files[0] == "-":
159166
files = [file.strip() for file in sys.stdin.readlines()]
160167
else:
161168
files = args.files
162-
163169
for filepath in files:
164170
filename = get_filename(filepath)
165171

172+
message(log_to, "File processed : " + filename)
166173
matched = file_pattern.match(filename)
167174

168175
if not matched:

0 commit comments

Comments
 (0)