Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(698)

Unified Diff: scripts/master/gerrit_poller.py

Issue 250983003: Added TryJobGerritScheduler (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/build
Patch Set: Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | scripts/master/try_job_gerrit.py » ('j') | scripts/master/try_job_gerrit.py » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: scripts/master/gerrit_poller.py
diff --git a/scripts/master/gerrit_poller.py b/scripts/master/gerrit_poller.py
index 57425fd740afd0da300c1fee9e55b9569cbcf26d..8ee9eb7df62172528be8a04bca06f7a56eacc746 100644
--- a/scripts/master/gerrit_poller.py
+++ b/scripts/master/gerrit_poller.py
@@ -34,10 +34,13 @@ class GerritPoller(base.PollingChangeSource):
self.initLastTimeStamp()
base.PollingChangeSource.startService(self)
+ def getChangeQuery(self):
+ return 'status:open'
+
@deferredLocked('initLock')
def initLastTimeStamp(self):
log.msg('GerritPoller: Getting latest timestamp from gerrit server.')
- path = '/changes/?q=status:open&n=1'
+ path = '/changes/?q=%s&n=1' % self.getChangeQuery()
d = self.agent.request('GET', path)
def _get_timestamp(j):
if len(j) == 0:
@@ -48,11 +51,14 @@ class GerritPoller(base.PollingChangeSource):
return d
def getChanges(self, sortkey=None):
- path = '/changes/?q=status:open&n=10'
+ path = '/changes/?q=%s&n=10' % self.getChangeQuery()
if sortkey:
path += '&N=%s' % sortkey
return self.agent.request('GET', path)
+ def _is_interesting_comment(self, comment):
+ return comment['message'].startswith('Uploaded patch set ')
+
def checkForNewPatchset(self, change, since):
o_params = '&'.join('o=%s' % x for x in (
'MESSAGES', 'CURRENT_REVISION', 'CURRENT_COMMIT', 'ALL_FILES'))
@@ -64,12 +70,12 @@ class GerritPoller(base.PollingChangeSource):
for m in reversed(j['messages']):
if self._parse_timestamp(m['date']) <= since:
break
- if m['message'].startswith('Uploaded patch set '):
- return j
+ if self._is_interesting_comment(m):
+ return j, m
d.addCallback(_parse_messages)
return d
- def createBuildbotChange(self, change):
+ def addBuildbotChange(self, change, comment):
revision = change['revisions'].values()[0]
commit = revision['commit']
properties = {'event.change.number': change['_number']}
@@ -95,12 +101,16 @@ class GerritPoller(base.PollingChangeSource):
'repository': '%s://%s/%s' % (
self.agent.gerrit_protocol, self.agent.gerrit_host,
change['project']),
- 'properties': properties}
+ 'properties': properties,
+ }
d = self.master.addChange(**chdict)
d.addErrback(log.err, 'GerritPoller: Could not add buildbot change for '
'gerrit change %s.' % revision['_number'])
return d
+ def addChange(self, (change, comment)):
+ return self.addBuildbotChange(change, comment)
+
def processChanges(self, j, since):
need_more = bool(j)
for change in j:
@@ -111,7 +121,7 @@ class GerritPoller(base.PollingChangeSource):
if self.gerrit_projects and change['project'] not in self.gerrit_projects:
continue
d = self.checkForNewPatchset(change, since)
- d.addCallback(lambda x: self.createBuildbotChange(x) if x else None)
+ d.addCallback(lambda x: self.addChange(x) if x else None)
if need_more and j[-1].get('_more_changes'):
d = self.getChanges(sortkey=j[-1]['_sortkey'])
d.addCallback(self.processChanges, since=since)
« no previous file with comments | « no previous file | scripts/master/try_job_gerrit.py » ('j') | scripts/master/try_job_gerrit.py » ('J')

Powered by Google App Engine
This is Rietveld 408576698