def _parse_messages(j): if not j or 'messages' not in j: return for m in reversed(j['messages']): if ParseGerritTime(m['date']) <= since: break if self._is_interesting_message(m): return j, m
def created_time(self): """Returns a 'datetime.datetime' corresponding to this change's 'created' field. If the field was missing, this will return 'None'. Return: A datetime.datetime object representing the created time, or None if the created time is not present. Raises: ValueError if the 'created' field could not be successfully parsed. """ result = self.get('created') if result is not None: result = ParseGerritTime(result) return result
def processChanges(self, j, since, skip=0): need_more = bool(j) for change in j: skip += 1 tm = ParseGerritTime(change['updated']) if tm <= since: need_more = False break if self.gerrit_projects and change[ 'project'] not in self.gerrit_projects: continue d = self.checkForNewPatchset(change, since) d.addCallback(lambda x: self.addChange(*x) if x else None) if need_more and j[-1].get('_more_changes'): d = self.getChanges(skip=skip) d.addCallback(self.processChanges, since=since, skip=skip) else: d = defer.succeed(None) return d
def date(self): return ParseGerritTime(self['date'])
def date(self): value = self._data.get('date') if value is None: return None return ParseGerritTime(value)
def _update_last_timestamp(j): if j: self.last_timestamp = ParseGerritTime(j[0]['updated']) return j
def addBuildbotChange(self, change, revision=None, additional_chdict=None): """Adds a buildbot change into the database. Args: change: ChangeInfo Gerrit object. Documentation: https://gerrit-review.googlesource.com/Documentation/rest-api-changes.html#change-info revision: the sha of the buildbot change revision to use. Defaults to the value of change['current_revision'] Returns the new buildbot change as Deferred. """ revision = revision or change['current_revision'] revision_details = change['revisions'][revision] commit = revision_details['commit'] properties = { 'event.change.number': change['_number'], 'event.change.id': change['id'], 'event.change.url': self.getChangeUrl(change), } if change['status'] == 'NEW': ref = revision_details.get('fetch', {}).get('http', {}).get('ref') if ref: properties['event.patchSet.ref'] = ref elif change['status'] in ('SUBMITTED', 'MERGED'): properties['event.refUpdate.newRev'] = revision chdict = { 'author': '%s <%s>' % (commit['author']['name'], commit['author']['email']), 'project': change['project'], 'branch': change['branch'], 'revision': revision, 'comments': commit['subject'], 'files': revision_details.get('files', { 'UNKNOWN': None }).keys(), 'category': self.change_category, 'when_timestamp': ParseGerritTime(commit['committer']['date']), 'revlink': self.getChangeUrl(change), 'repository': self.getRepositoryUrl(change), 'properties': properties, } # Factor in external 'chdict' overrides. if additional_chdict is not None: properties.update(additional_chdict.pop('properties', {})) chdict.update(additional_chdict) chdict['properties'] = properties d = self.master.addChange(**chdict) d.addErrback( log.err, 'GerritPoller: Could not add buildbot change for ' 'gerrit change %s.' % revision_details['_number']) return d
def _get_timestamp(j): if len(j) == 0: self.last_timestamp = datetime.datetime.now() else: self.last_timestamp = ParseGerritTime(j[0]['updated'])