| Index: owners.py
|
| diff --git a/owners.py b/owners.py
|
| index cc667beea3c575f527470d9bd25269b4e95c6bae..d4a1dc7ca3137b4dea88713df9bfaa88f05fed37 100644
|
| --- a/owners.py
|
| +++ b/owners.py
|
| @@ -111,6 +111,9 @@ class Database(object):
|
| # Mapping of paths to authorized owners.
|
| self.owners_for = {}
|
|
|
| + # Mapping reviewers to the most recent comment in the OWNERS files.
|
| + self.comments = {}
|
| +
|
| # Set of paths that stop us from looking above them for owners.
|
| # (This is implicitly true for the root directory).
|
| self.stop_looking = set([''])
|
| @@ -195,13 +198,23 @@ class Database(object):
|
| owners_path = self.os_path.join(self.root, dirpath, 'OWNERS')
|
| if not self.os_path.exists(owners_path):
|
| return
|
| -
|
| + comment = ""
|
| + last_line_is_comment = False
|
| lineno = 0
|
| for line in self.fopen(owners_path):
|
| lineno += 1
|
| line = line.strip()
|
| - if line.startswith('#') or line == '':
|
| + if line.startswith('#'):
|
| + if last_line_is_comment:
|
| + comment += " " + line[1:].strip()
|
| + else:
|
| + comment = line[1:].strip()
|
| + last_line_is_comment = True
|
| continue
|
| + if line == '':
|
| + continue
|
| + last_line_is_comment = False
|
| +
|
| if line == 'set noparent':
|
| self.stop_looking.add(dirpath)
|
| continue
|
| @@ -218,19 +231,23 @@ class Database(object):
|
| baselines = self.glob(full_glob_string)
|
| for baseline in (self.os_path.relpath(b, self.root) for b in baselines):
|
| self._add_entry(baseline, directive, "per-file line",
|
| - owners_path, lineno)
|
| + owners_path, lineno, comment)
|
| continue
|
|
|
| if line.startswith('set '):
|
| raise SyntaxErrorInOwnersFile(owners_path, lineno,
|
| 'unknown option: "%s"' % line[4:].strip())
|
|
|
| - self._add_entry(dirpath, line, "line", owners_path, lineno)
|
| + self._add_entry(dirpath, line, "line", owners_path, lineno, comment)
|
|
|
| - def _add_entry(self, path, directive, line_type, owners_path, lineno):
|
| + def _add_entry(self, path, directive,
|
| + line_type, owners_path, lineno, comment):
|
| if directive == "set noparent":
|
| self.stop_looking.add(path)
|
| elif self.email_regexp.match(directive) or directive == EVERYONE:
|
| + if directive not in self.comments:
|
| + self.comments[directive] = {}
|
| + self.comments[directive][self.os_path.dirname(path)] = comment
|
| self.owned_by.setdefault(directive, set()).add(path)
|
| self.owners_for.setdefault(path, set()).add(directive)
|
| else:
|
|
|