Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
| 3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
| 4 | 4 |
| 5 """A database of OWNERS files. | 5 """A database of OWNERS files. |
| 6 | 6 |
| 7 OWNERS files indicate who is allowed to approve changes in a specific directory | 7 OWNERS files indicate who is allowed to approve changes in a specific directory |
| 8 (or who is allowed to make changes without needing approval of another OWNER). | 8 (or who is allowed to make changes without needing approval of another OWNER). |
| 9 Note that all changes must still be reviewed by someone familiar with the code, | 9 Note that all changes must still be reviewed by someone familiar with the code, |
| 10 so you may need approval from both an OWNER and a reviewer in many cases. | 10 so you may need approval from both an OWNER and a reviewer in many cases. |
| 11 | 11 |
| 12 The syntax of the OWNERS file is, roughly: | 12 The syntax of the OWNERS file is, roughly: |
| 13 | 13 |
| 14 lines := (\s* line? \s* "\n")* | 14 lines := (\s* line? \s* "\n")* |
| 15 | 15 |
| 16 line := directive | 16 line := directive |
| 17 | "per-file" \s+ glob "=" directive | 17 | "per-file" \s+ glob \s* "=" \s* directive |
| 18 | comment | 18 | comment |
| 19 | 19 |
| 20 directive := "set noparent" | 20 directive := "set noparent" |
| 21 | email_address | 21 | email_address |
| 22 | "*" | 22 | "*" |
| 23 | 23 |
| 24 glob := [a-zA-Z0-9_-*?]+ | 24 glob := [a-zA-Z0-9_-*?]+ |
| 25 | 25 |
| 26 comment := "#" [^"\n"]* | 26 comment := "#" [^"\n"]* |
| 27 | 27 |
| (...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 212 lineno = 0 | 212 lineno = 0 |
| 213 for line in self.fopen(owners_path): | 213 for line in self.fopen(owners_path): |
| 214 lineno += 1 | 214 lineno += 1 |
| 215 line = line.strip() | 215 line = line.strip() |
| 216 if line.startswith('#') or line == '': | 216 if line.startswith('#') or line == '': |
| 217 continue | 217 continue |
| 218 if line == 'set noparent': | 218 if line == 'set noparent': |
| 219 self.stop_looking.add(dirpath) | 219 self.stop_looking.add(dirpath) |
| 220 continue | 220 continue |
| 221 | 221 |
| 222 m = re.match("per-file (.+)=(.+)", line) | 222 m = re.match("per-file (.+)=(.+)", line) |
|
M-A Ruel
2012/11/30 18:37:31
why not
re.match(r"per-file\s+(.+)\s*=\s*(.+)\s*",
| |
| 223 if m: | 223 if m: |
| 224 glob_string = m.group(1) | 224 glob_string = m.group(1).strip() |
| 225 directive = m.group(2) | 225 directive = m.group(2).strip() |
| 226 full_glob_string = self.os_path.join(self.root, dirpath, glob_string) | 226 full_glob_string = self.os_path.join(self.root, dirpath, glob_string) |
| 227 if '/' in glob_string or '\\' in glob_string: | 227 if '/' in glob_string or '\\' in glob_string: |
| 228 raise SyntaxErrorInOwnersFile(owners_path, lineno, | 228 raise SyntaxErrorInOwnersFile(owners_path, lineno, |
| 229 'per-file globs cannot span directories or use escapes: "%s"' % | 229 'per-file globs cannot span directories or use escapes: "%s"' % |
| 230 line) | 230 line) |
| 231 baselines = self.glob(full_glob_string) | 231 baselines = self.glob(full_glob_string) |
| 232 for baseline in (self.os_path.relpath(b, self.root) for b in baselines): | 232 for baseline in (self.os_path.relpath(b, self.root) for b in baselines): |
| 233 self._add_entry(baseline, directive, "per-file line", | 233 self._add_entry(baseline, directive, "per-file line", |
| 234 owners_path, lineno) | 234 owners_path, lineno) |
| 235 continue | 235 continue |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 300 break | 300 break |
| 301 | 301 |
| 302 final_owners.add(max_owner) | 302 final_owners.add(max_owner) |
| 303 | 303 |
| 304 # Remove all directories owned by the current owner from the remaining | 304 # Remove all directories owned by the current owner from the remaining |
| 305 # list. | 305 # list. |
| 306 for dirname in owned_dirs[max_owner]: | 306 for dirname in owned_dirs[max_owner]: |
| 307 dirs.discard(dirname) | 307 dirs.discard(dirname) |
| 308 | 308 |
| 309 return final_owners | 309 return final_owners |
| OLD | NEW |