--- a/poller-queue.py Thu Nov 17 00:33:40 2016 +0800
+++ b/poller-queue.py Thu Nov 17 00:36:02 2016 +0800
if target['type'] == 'hgweb':
+ elif target['type'] == 'github':
class CandolintPoller(Application):
if target['type'] == 'hgweb':
self.parse_hgweb(target, data)
+ elif target['type'] == 'github':
+ self.parse_github(target, data)
target['etag'] = response.headers.get('ETag', None)
elif response.code == 304:
logging.info('Got %d current hash(es) from %s', len(hashes), target['poll'])
target['hashes'] = hashes
+ def parse_github(self, target, data):
+ hashes = {branch['name']: branch['commit']['sha'] for branch in data}
+ for name, sha in hashes.items():
+ if target['hashes'].get(name) != sha:
+ 'repo': target['repo'],
+ 'source': target['source'],
+ 'timestamp': timestamp()
+ logging.info('Got %d new hash(es) from %s', len(new), target['poll'])
+ logging.info('Got %d current hash(es) from %s', len(hashes), target['poll'])
+ target['hashes'] = hashes
def push(self, base, changes):