hgpoll.py

changeset 110
b2770c43b752
parent 109
87ad0c1b3405
child 111
44d9aea72947
equal deleted inserted replaced
109:87ad0c1b3405 110:b2770c43b752
5 import irc as Irc 5 import irc as Irc
6 import os 6 import os
7 from datetime import datetime 7 from datetime import datetime
8 from configfile import Config 8 from configfile import Config
9 g_needCommitsTxtRebuild = True 9 g_needCommitsTxtRebuild = True
10
11 def color_for_repo (repo_name):
12 if repo_name == 'zandronum':
13 color = 4
14 elif repo_name == 'zandronum-stable':
15 color = 2
16 elif repo_name == 'zandronum-sandbox':
17 color = 7
18 elif repo_name == 'zandronum-sandbox-stable':
19 color = 3
20 else:
21 color = 0
22 return color
10 23
11 def make_commits_txt(): 24 def make_commits_txt():
12 global g_needCommitsTxtRebuild 25 global g_needCommitsTxtRebuild
13 26
14 if g_needCommitsTxtRebuild == False: 27 if g_needCommitsTxtRebuild == False:
167 # Announce on IRC 180 # Announce on IRC
168 for irc_client in Irc.all_clients: 181 for irc_client in Irc.all_clients:
169 for channel in irc_client.channels: 182 for channel in irc_client.channels:
170 if channel.get_value ('btannounce', default=True): 183 if channel.get_value ('btannounce', default=True):
171 irc_client.privmsg (channel.get_value ('name'), 184 irc_client.privmsg (channel.get_value ('name'),
172 "%s: commit %s FIXES issue %d" % (repo_name, commit_node, ticket_id)) 185 "\003%d%s\003: commit\0035 %s\003 addresses issue\002\0032 %d\002" % (color_for_repo (repo_name), repo_name, commit_node, ticket_id))
173 irc_client.privmsg (channel.get_value ('name'), 186 irc_client.privmsg (channel.get_value ('name'),
174 "Read all about it here: " + Bt.get_ticket_url (ticket_id)) 187 "Read all about it here: " + Bt.get_ticket_url (ticket_id))
175 188
176 if need_update: 189 if need_update:
177 # We need to remove the note data, otherwise the ticket notes 190 # We need to remove the note data, otherwise the ticket notes
285 usesandbox = repo_name == 'zandronum-sandbox' or repo_name == 'zandronum-sandbox-stable' 298 usesandbox = repo_name == 'zandronum-sandbox' or repo_name == 'zandronum-sandbox-stable'
286 repo_owner = 'Torr_Samaho' if not usesandbox else 'crimsondusk' 299 repo_owner = 'Torr_Samaho' if not usesandbox else 'crimsondusk'
287 repo_url = 'https://bitbucket.org/%s/%s' % (repo_owner, repo_name) 300 repo_url = 'https://bitbucket.org/%s/%s' % (repo_owner, repo_name)
288 num_commits = 0 301 num_commits = 0
289 zanrepo = hgapi.Repo (repo_name) 302 zanrepo = hgapi.Repo (repo_name)
290 Irc.broadcast ('%d new commits on %s' % (len (commit_data), repo_name)) 303 print '%d new commits on %s' % (len (commit_data), repo_name)
291 304
292 # Drop commits that we already have 305 # Drop commits that we already have
293 i = 0 306 i = 0
294 while i < len (commit_data): 307 while i < len (commit_data):
295 try: 308 try:
352 365
353 for irc_client in Irc.all_clients: 366 for irc_client in Irc.all_clients:
354 for channel in irc_client.channels: 367 for channel in irc_client.channels:
355 if not usesandbox or channel.get_value ('btprivate', False): 368 if not usesandbox or channel.get_value ('btprivate', False):
356 irc_client.privmsg (channel.get_value ('name'), 369 irc_client.privmsg (channel.get_value ('name'),
357 "%s: new commit %s by %s: %s" 370 "\003%d%s\003: new commit\0035 %s\003 by\0032 %s\003: %s"
358 % (repo_name, commit_node, committer, commit_url)) 371 % (color_for_repo (repo_name), repo_name, commit_node, committer, commit_url))
359 372
360 for line in commit_message.split ('\n'): 373 for line in commit_message.split ('\n'):
361 irc_client.privmsg (channel.get_value ('name'), line) 374 irc_client.privmsg (channel.get_value ('name'), line)
362 375
363 if not usesandbox: 376 if not usesandbox:

mercurial