Commit 7f75c0e9 authored by John Budorick's avatar John Budorick Committed by Commit Bot

owners: fix inline comment support in included files.

The parsing logic for OWNERS files included via "file:" lines currently
rejects inline comments (e.g. "foo@example.com  # for foo.cc"), while
the normal OWNERS parsing logic correctly ignores such inline comments.
This CL makes the inline case ignore inline comments too.

Bug: 995474
Change-Id: I6f30554daf0a5f63b81719dced44f59187707eaa
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/1769603Reviewed-by: 's avatarEdward Lesmes <ehmaldonado@chromium.org>
Commit-Queue: John Budorick <jbudorick@chromium.org>
parent 2d6b67c5
......@@ -478,6 +478,10 @@ class Database(object):
line.startswith('per-file')):
continue
# If the line ends with a comment, strip the comment.
line, _delim, _comment = line.partition('#')
line = line.strip()
if self.email_regexp.match(line) or line == EVERYONE:
owners.add(line)
continue
......
......@@ -48,10 +48,13 @@ def test_repo():
'/chrome/browser/defaults.h': '',
'/chrome/gpu/OWNERS': owners_file(ken),
'/chrome/gpu/gpu_channel.h': '',
'/chrome/comment/OWNERS': owners_file(file='//content/comment/OWNERS'),
'/chrome/renderer/OWNERS': owners_file(peter),
'/chrome/renderer/gpu/gpu_channel_host.h': '',
'/chrome/renderer/safe_browsing/scorer.h': '',
'/content/OWNERS': owners_file(john, darin, comment='foo', noparent=True),
'/content/comment/OWNERS': owners_file(john + ' # for comments',
darin + ' # for everything else'),
'/content/content.gyp': '',
'/content/bar/foo.cc': '',
'/content/baz/OWNERS': owners_file(brett),
......@@ -321,6 +324,10 @@ class OwnersDatabaseTest(_BaseTestCase):
except owners.SyntaxErrorInOwnersFile as e:
self.assertTrue(str(e).startswith('/ipc/OWNERS:1'))
def test_file_include_with_comment(self):
# See crbug.com/995474 for context.
self.assert_files_not_covered_by(['chrome/comment/comment.cc'], [darin], [])
def assert_syntax_error(self, owners_file_contents):
db = self.db()
self.files['/foo/OWNERS'] = owners_file_contents
......
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