def ValidateOwnersConfig(self, change_id): data = gerrit_util.GetChange(self._host, change_id, [ 'DETAILED_ACCOUNTS', 'DETAILED_LABELS', 'CURRENT_FILES', 'CURRENT_REVISION' ]) files = data['revisions'][data['current_revision']]['files'] db = owners_db.Database(self._root, self._fopen, self._os_path) try: db.load_data_needed_for( [f for f in files if os.path.basename(f) == 'OWNERS']) except Exception as e: raise InvalidOwnersConfig('Error parsing OWNERS files:\n%s' % e)
def GetChangeApprovalStatus(self, change_id): data = gerrit_util.GetChange(self._host, change_id, [ 'DETAILED_ACCOUNTS', 'DETAILED_LABELS', 'CURRENT_FILES', 'CURRENT_REVISION' ]) reviewers = [r['email'] for r in data['reviewers']['REVIEWER']] # Get reviewers that have approved this change label = data['labels']['Code-Review'] max_value = max(int(v) for v in label['values']) approvers = [ v['email'] for v in label['all'] if v['value'] == max_value ] files = data['revisions'][data['current_revision']]['files'] return self.GetFilesApprovalStatus(None, None, files, approvers, reviewers)