aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChih-Hung Hsieh <chh@google.com>2018-08-15 16:07:27 -0700
committerChih-Hung Hsieh <chh@google.com>2018-08-20 14:16:04 -0700
commitf77c7f75e55af504db3905745b424b800d75d7d1 (patch)
treed32aceb5a2afb5084e3363e5ff87a53252dbf7c4
parentc9f31dff01069b231bc0ba0f15e9f553c30bc1a6 (diff)
downloadplatform_build-f77c7f75e55af504db3905745b424b800d75d7d1.tar.gz
platform_build-f77c7f75e55af504db3905745b424b800d75d7d1.tar.bz2
platform_build-f77c7f75e55af504db3905745b424b800d75d7d1.zip
Use multiple globs/emails in per-file syntax
Bug: 112259427 Test: tools/checkowners.py -c -v OWNERS */OWNERS */*/OWNERS Change-Id: I0e2c2c64a23df360fbe7691c4336ca04099fba13
-rw-r--r--OWNERS7
-rw-r--r--core/OWNERS9
-rw-r--r--tools/OWNERS3
-rwxr-xr-xtools/checkowners.py42
4 files changed, 29 insertions, 32 deletions
diff --git a/OWNERS b/OWNERS
index 1e9b7634f7..b9fee4e1ae 100644
--- a/OWNERS
+++ b/OWNERS
@@ -2,10 +2,7 @@ ccross@android.com
dwillemsen@google.com
nanzhang@google.com
-per-file * = ccross@android.com
-per-file * = dwillemsen@google.com
-per-file * = nanzhang@google.com
+per-file * = ccross@android.com,dwillemsen@google.com,nanzhang@google.com
# for version updates
-per-file version_defaults.mk = aseaton@google.com
-per-file version_defaults.mk = elisapascual@google.com
+per-file version_defaults.mk = aseaton@google.com,elisapascual@google.com
diff --git a/core/OWNERS b/core/OWNERS
index 4045061daf..570ede8a4d 100644
--- a/core/OWNERS
+++ b/core/OWNERS
@@ -1,8 +1 @@
-per-file * = ccross@android.com
-per-file * = dwillemsen@google.com
-per-file * = nanzhang@google.com
-
-per-file dex_preopt*.mk = ngeoffray@google.com
-per-file dex_preopt*.mk = calin@google.com
-per-file dex_preopt*.mk = mathewi@google.com
-per-file dex_preopt*.mk = dbrazdil@google.com
+per-file dex_preopt*.mk = ngeoffray@google.com,calin@google.com,mathewi@google.com,dbrazdil@google.com
diff --git a/tools/OWNERS b/tools/OWNERS
index 7a23adce9b..7d666f1687 100644
--- a/tools/OWNERS
+++ b/tools/OWNERS
@@ -1,2 +1 @@
-per-file warn.py = chh@google.com
-per-file checkowners.py = chh@google.com
+per-file warn.py,checkowners.py = chh@google.com
diff --git a/tools/checkowners.py b/tools/checkowners.py
index 54198a7e96..8568ccf861 100755
--- a/tools/checkowners.py
+++ b/tools/checkowners.py
@@ -35,22 +35,31 @@ def find_address(address):
echo('Checking email address: ' + address)
result = urllib2.urlopen(request).read()
checked_addresses[address] = result.find('"_account_id":') >= 0
+ if checked_addresses[address]:
+ echo('Found email address: ' + address)
return checked_addresses[address]
+def check_address(fname, num, address):
+ if find_address(address):
+ return 0
+ print '%s:%d: ERROR: unknown email address: %s' % (fname, num, address)
+ return 1
+
+
def main():
# One regular expression to check all valid lines.
noparent = 'set +noparent'
email = '([^@ ]+@[^ @]+|\\*)'
- directive = '(%s|%s)' % (email, noparent)
+ emails = '(%s( *, *%s)*)' % (email, email)
+ directive = '(%s|%s)' % (emails, noparent)
glob = '[a-zA-Z0-9_\\.\\-\\*\\?]+'
- perfile = 'per-file +' + glob + ' *= *' + directive
+ globs = '(%s( *, *%s)*)' % (glob, glob)
+ perfile = 'per-file +' + globs + ' *= *' + directive
pats = '(|%s|%s|%s)$' % (noparent, email, perfile)
patterns = re.compile(pats)
-
- # One pattern to capture email address.
- email_address = '.*(@| |=|^)([^@ =]+@[^ @]+)'
- address_pattern = re.compile(email_address)
+ address_pattern = re.compile('([^@ ]+@[^ @]+)')
+ perfile_pattern = re.compile('per-file +.*=(.*)')
error = 0
for fname in args.owners:
@@ -60,17 +69,16 @@ def main():
num += 1
stripped_line = re.sub('#.*$', '', line).strip()
if not patterns.match(stripped_line):
- error = 1
- print('%s:%d: ERROR: unknown line [%s]'
- % (fname, num, line.strip()))
- elif args.check_address and address_pattern.match(stripped_line):
- address = address_pattern.match(stripped_line).group(2)
- if find_address(address):
- echo('Found email address: ' + address)
- else:
- error = 1
- print('%s:%d: ERROR: unknown email address: %s'
- % (fname, num, address))
+ error += 1
+ print '%s:%d: ERROR: unknown line [%s]' % (fname, num, line.strip())
+ elif args.check_address:
+ if perfile_pattern.match(stripped_line):
+ for addr in perfile_pattern.match(stripped_line).group(1).split(','):
+ a = addr.strip()
+ if a and a != '*':
+ error += check_address(fname, num, addr.strip())
+ elif address_pattern.match(stripped_line):
+ error += check_address(fname, num, stripped_line)
sys.exit(error)
if __name__ == '__main__':