Example #1
0
 def ListOwners(self, path):
     # GetOwnersForFile returns a list of account details sorted by order of
     # best reviewer for path. If owners have the same score, the order is
     # random.
     data = gerrit_util.GetOwnersForFile(self._host, self._project,
                                         self._branch, path)
     return [d['account']['email'] for d in data['code_owners']]
 def ListOwners(self, path):
   # Always use slashes as separators.
   path = path.replace(os.sep, '/')
   if path not in self._owners_cache:
     # GetOwnersForFile returns a list of account details sorted by order of
     # best reviewer for path. If owners have the same score, the order is
     # random.
     data = gerrit_util.GetOwnersForFile(
         self._host, self._project, self._branch, path,
         resolve_all_users=False)
     self._owners_cache[path] = [
       d['account']['email']
       for d in data['code_owners']
       if 'account' in d and 'email' in d['account']
     ]
     # If owned_by_all_users is true, add everyone as an owner at the end of
     # the owners list.
     if data.get('owned_by_all_users', False):
       self._owners_cache[path].append(self.EVERYONE)
   return self._owners_cache[path]