Add support for notification of releases on IRC
Closes-Bug: #1227985 Change-Id: I9b80b465d9d6b0e2793286cc8229b82b4389a08d
This commit is contained in:
parent
cf56901920
commit
575b062cbd
@ -50,6 +50,7 @@ import daemon
|
|||||||
import irc.bot
|
import irc.bot
|
||||||
import logging.config
|
import logging.config
|
||||||
import os
|
import os
|
||||||
|
import re
|
||||||
import ssl
|
import ssl
|
||||||
import sys
|
import sys
|
||||||
import threading
|
import threading
|
||||||
@ -154,6 +155,20 @@ class Gerrit(threading.Thread):
|
|||||||
self.log.info('Compiled Message %s: %s' % (channel, msg))
|
self.log.info('Compiled Message %s: %s' % (channel, msg))
|
||||||
self.ircbot.send(channel, msg)
|
self.ircbot.send(channel, msg)
|
||||||
|
|
||||||
|
def ref_updated(self, channel, data):
|
||||||
|
refName = data['refUpdate']['refName']
|
||||||
|
m = re.match(r'(refs/tags)/(.*)', refName)
|
||||||
|
|
||||||
|
if m:
|
||||||
|
tag = m.group(2)
|
||||||
|
msg = '%s tagged project %s with %s' % (
|
||||||
|
data['submitter']['username'],
|
||||||
|
data['refUpdate']['project'],
|
||||||
|
tag
|
||||||
|
)
|
||||||
|
self.log.info('Compiled Message %s: %s' % (channel, msg))
|
||||||
|
self.ircbot.send(channel, msg)
|
||||||
|
|
||||||
def comment_added(self, channel, data):
|
def comment_added(self, channel, data):
|
||||||
msg = 'A comment has been added to a proposed change to %s: %s %s' % (
|
msg = 'A comment has been added to a proposed change to %s: %s %s' % (
|
||||||
data['change']['project'],
|
data['change']['project'],
|
||||||
@ -213,12 +228,15 @@ class Gerrit(threading.Thread):
|
|||||||
|
|
||||||
def _read(self, data):
|
def _read(self, data):
|
||||||
try:
|
try:
|
||||||
channel_set = (self.channel_config.projects.get(
|
if data['type'] == 'ref-updated':
|
||||||
data['change']['project'], set()) &
|
channel_set = self.channel_config.events.get('ref-updated')
|
||||||
self.channel_config.events.get(
|
else:
|
||||||
data['type'], set()) &
|
channel_set = (self.channel_config.projects.get(
|
||||||
self.channel_config.branches.get(
|
data['change']['project'], set()) &
|
||||||
data['change']['branch'], set()))
|
self.channel_config.events.get(
|
||||||
|
data['type'], set()) &
|
||||||
|
self.channel_config.branches.get(
|
||||||
|
data['change']['branch'], set()))
|
||||||
except KeyError:
|
except KeyError:
|
||||||
# The data we care about was not present, no channels want
|
# The data we care about was not present, no channels want
|
||||||
# this event.
|
# this event.
|
||||||
@ -232,6 +250,8 @@ class Gerrit(threading.Thread):
|
|||||||
self.patchset_created(channel, data)
|
self.patchset_created(channel, data)
|
||||||
elif data['type'] == 'change-merged':
|
elif data['type'] == 'change-merged':
|
||||||
self.change_merged(channel, data)
|
self.change_merged(channel, data)
|
||||||
|
elif data['type'] == 'ref-updated':
|
||||||
|
self.ref_updated(channel, data)
|
||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
while True:
|
while True:
|
||||||
|
Loading…
Reference in New Issue
Block a user