# HG changeset patch # User Teemu Piippo # Date 1411953359 -10800 # Node ID 88899b43810bea493f3f8feab4036d227731998e # Parent 4e3259daa425b762feabef23aaeaf813d5228270 - corrected repository handling on error: print errors with commit node and pull even when processing fails - fixed: as a result of cobalt today being given updater status due to the recent repository tracking feature, it would leak out private ticket info diff -r 4e3259daa425 -r 88899b43810b cobalt.py --- a/cobalt.py Mon Sep 29 03:30:47 2014 +0300 +++ b/cobalt.py Mon Sep 29 04:15:59 2014 +0300 @@ -278,9 +278,10 @@ continue #fi + commit_node = match.group (1) + commit_message = match.group (2) + try: - commit_node = match.group (1) - commit_message = match.group (2) rex = re.compile (r'^.*(fixes|resolves|addresses) ([0-9]+).*$') match = rex.match (commit_message) @@ -409,13 +410,11 @@ suds_client.service.mc_issue_note_add (g_config['trackeruser'], g_config['trackerpassword'], ticket_id, { 'text': message }) except Exception as e: - chanlog ('Error: %s' % `e`) + chanlog ('Error while processing %s: %s' % (commit_node, `e`)) failed = True #tried - if not failed: - commits_to_pull.append (commit_node) - #fi + commits_to_pull.append (commit_node) #done if len (commits_to_pull) > 0: @@ -633,6 +632,22 @@ self.privmsg (replyto, "Failed to get info for issue %s: %s" % (ticket, `e`)) if data: + if data['view_state']['name'] == 'private': + allowprivate = False + + for channel in self.channels: + if channel['name'] == replyto and 'btprivate' in channel and channel['btprivate'] == True: + allowprivate = True + break + #fi + #done + + if not allowprivate: + self.privmsg (replyto, 'Error: ticket %s is private' % ticket) + return + #fi + #fi + self.privmsg (replyto, "Issue %s: %s: Reporter: %s, assigned to: %s, status: %s (%s)" % \ (ticket, \ data.summary, \ @@ -643,6 +658,9 @@ if withlink: self.privmsg (replyto, "Read all about it here: " + self.get_ticket_url (ticket)) + #fi + #fi + #enddef # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # @@ -783,6 +801,8 @@ channel['password'] = value elif key == 'btannounce': channel['btannounce'] = bool_from_string (value) + elif key == 'btprivate': + channel['btprivate'] = bool_from_string (value) elif key == 'logchannel': channel['logchannel'] = bool_from_string (value) else: @@ -923,12 +943,18 @@ while len(idstring) < 7: idstring = "0" + idstring + isprivate = data['view_state']['name'] == 'private' reporter = data['reporter']['name'] if hasattr (data['reporter'], 'name') else '' for channel in self.cfg['channels']: if 'btannounce' in channel and channel['btannounce'] == True: - self.write ("PRIVMSG %s :[%s] New issue %s, reported by %s: %s: %s" % \ - (channel['name'], data['project']['name'], idstring, reporter, data['summary'], self.get_ticket_url (idstring))) + if not isprivate or ('btprivate' in channel and channel['btprivate'] == True): + self.write ("PRIVMSG %s :[%s] New issue %s, reported by %s: %s: %s" % \ + (channel['name'], data['project']['name'], idstring, reporter, + data['summary'], self.get_ticket_url (idstring))) + #fi + #fi + #done def handle_error(self): excepterm (traceback.format_exception(sys.exc_type, sys.exc_value, sys.exc_traceback))