Commit e3991bc4 authored by Jochen Eisinger's avatar Jochen Eisinger Committed by Commit Bot

Also check override files before checking the fs

A CL might delete an OWNERS file which we still need to read for the OWNERS
check.

BUG=778870
R=agable@chromium.org

Change-Id: I25636ff36228a1afb3c10edf5c2419773a4d057e
Reviewed-on: https://chromium-review.googlesource.com/754623Reviewed-by: 's avatarAaron Gable <agable@chromium.org>
Commit-Queue: Jochen Eisinger <jochen@chromium.org>
parent 3b74d333
......@@ -231,7 +231,7 @@ class Database(object):
def _read_owners(self, path):
owners_path = self.os_path.join(self.root, path)
if not self.os_path.exists(owners_path):
if not (self.os_path.exists(owners_path) or (path in self.override_files)):
return
if owners_path in self.read_files:
......@@ -379,6 +379,9 @@ class Database(object):
start = self.os_path.dirname(self.os_path.relpath(start, self.root))
include_path = self.os_path.join(start, path)
if include_path in self.override_files:
return include_path
owners_path = self.os_path.join(self.root, include_path)
if not self.os_path.exists(owners_path):
return None
......@@ -392,7 +395,11 @@ class Database(object):
owners = set()
self._included_files[include_file] = owners
lineno = 0
for line in self.fopen(self.os_path.join(self.root, include_file)):
if include_file in self.override_files:
file_iter = self.override_files[include_file]
else:
file_iter = self.fopen(self.os_path.join(self.root, include_file))
for line in file_iter:
lineno += 1
line = line.strip()
if (line.startswith('#') or line == '' or
......
......@@ -506,6 +506,10 @@ class ReviewersForTest(_BaseTestCase):
override_files={'content/baz/OWNERS': [jochen]})
self.assert_reviewers_for(['content/baz/froboz.h'], [[john],[darin]],
override_files={'content/baz/OWNERS': []})
self.assert_reviewers_for(
['content/baz/froboz.h'], [[jochen]],
override_files={'content/baz/OWNERS': ['file://JOCHEN_OWNERS'],
'JOCHEN_OWNERS': [jochen]})
class LowestCostOwnersTest(_BaseTestCase):
......
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