Commit dd007670 authored by Dirk Pranke's avatar Dirk Pranke Committed by LUCI CQ

Try again to fix UnicodeDecodeError in CheckAuthorizedAuthor.

This will attempt to do so in a Python2-compatible way.

Bug: 1210746
Change-Id: I09edc21a5c47106803c0ac5ca449e0f8732efb24
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/2906501
Auto-Submit: Dirk Pranke <dpranke@google.com>
Reviewed-by: 's avatarEdward Lesmes <ehmaldonado@chromium.org>
Commit-Queue: Edward Lesmes <ehmaldonado@chromium.org>
parent 4914c837
......@@ -126,10 +126,14 @@ def CheckAuthorizedAuthor(input_api, output_api, bot_allowlist=None):
authors_path = input_api.os_path.join(
input_api.PresubmitLocalPath(), 'AUTHORS')
valid_authors = (
input_api.re.match(r'[^#]+\s+\<(.+?)\>\s*$', line)
for line in open(authors_path))
valid_authors = [item.group(1).lower() for item in valid_authors if item]
author_re = input_api.re.compile(r'[^#]+\s+\<(.+?)\>\s*$')
valid_authors = []
with open(authors_path, 'rb') as fp:
for line in fp:
m = author_re.match(line.decode('utf8'))
if m:
valid_authors.append(m.group(1)).lower()
if not any(input_api.fnmatch.fnmatch(author.lower(), valid)
for valid in valid_authors):
input_api.logging.info('Valid authors are %s', ', '.join(valid_authors))
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment