Sat, 29 Nov 2014 16:37:36 +0200
- link rest to hg
hgpoll.py | file | annotate | diff | comparison | revisions | |
rest.py | file | annotate | diff | comparison | revisions |
--- a/hgpoll.py Fri Nov 28 23:24:06 2014 -0500 +++ b/hgpoll.py Sat Nov 29 16:37:36 2014 +0200 @@ -279,7 +279,10 @@ commit_message = match.group (2) commit_data.append ([commit_node, commit_message]) - print '%d new commits on %s' % (len (commit_data), repo_name) + process_new_commits (repo_name, commit_data) + +def process_new_commits (repo_name, commit_data): + Irc.broadcast ('%d new commits on %s' % (len (commit_data), repo_name)) if len (commit_data) > 0: pull_args = [];
--- a/rest.py Fri Nov 28 23:24:06 2014 -0500 +++ b/rest.py Sat Nov 29 16:37:36 2014 +0200 @@ -10,14 +10,14 @@ import irc as Irc from datetime import datetime, timedelta from configfile import Config +import hgpoll as HgPoll g_credentials = None g_portnumber = None g_throttle = [] valid_repos = ['Torr_Samaho/zandronum', 'Torr_Samaho/zandronum-stable', - 'crimsondusk/zandronum-sandbox', 'crimsondusk/zandronum-sandbox-stable', - 'crimsondusk/testrepo'] + 'crimsondusk/zandronum-sandbox', 'crimsondusk/zandronum-sandbox-stable'] def is_throttled (address): i = 0 @@ -84,14 +84,19 @@ try: jsondata = json.loads (jsonstring) repodata = jsondata['repository'] - repopath = '%s/%s' % (repodata['owner'], repodata['name']) + repo_name = '%s/%s' % (repodata['owner'], repodata['name']) - if repopath not in valid_repos: - raise ValueError ('unknown repository %s' % repopath) + if repo_name not in valid_repos: + raise ValueError ('unknown repository %s' % repo_name) + + commit_data = [] if 'commits' in jsondata: for commit in jsondata['commits']: - Irc.broadcast ('%s: new commit %s' % (address, commit['node'])) + commit_data.append ([commit['node'], commit['message']]) + + if len (commit_data) > 0: + HgPoll.process_new_commits (repo_name, commit_data) except Exception as e: Irc.broadcast ('%s provided bad JSON: %s' % (address, e))