diff --git a/owners.py b/owners.py index e264b59460..602fd31149 100644 --- a/owners.py +++ b/owners.py @@ -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 diff --git a/tests/owners_unittest.py b/tests/owners_unittest.py index 2b308da704..5998c46d92 100755 --- a/tests/owners_unittest.py +++ b/tests/owners_unittest.py @@ -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