From 75e2c2f03d9fc5b6d8d193186428837701ac41d5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rados=C5=82aw=20Piliszek?= Date: Wed, 28 Apr 2021 18:17:52 +0000 Subject: [PATCH] Add branch to all the remaining event messages Branch is always useful to know. ;-) Change-Id: Icece8d06c771dbd55825655206f75810d9fa43e6 --- gerritbot/bot.py | 15 ++++++++++----- gerritbot/tests/unit/test_bot.py | 4 ++-- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/gerritbot/bot.py b/gerritbot/bot.py index 4ab7712..60eee04 100755 --- a/gerritbot/bot.py +++ b/gerritbot/bot.py @@ -211,8 +211,9 @@ class Gerrit(threading.Thread): def comment_added(self, channel, data): if channel in self._channels_for('events', 'x-all-comments'): - msg = 'A comment has been added to %s: %s %s' % ( + msg = 'A comment has been added to %s %s: %s %s' % ( data['change']['project'], + data['change']['branch'], data['change']['subject'], data['change']['url']) self.log.info('Compiled Message %s: %s' % (channel, msg)) @@ -222,8 +223,9 @@ class Gerrit(threading.Thread): if (approval['type'] == 'Verified' and approval['value'] == '-2' and channel in self._channels_for('events', 'x-vrif-minus-2')): - msg = 'Verification of a change to %s failed: %s %s' % ( + msg = 'Verification of a change to %s %s failed: %s %s' % ( data['change']['project'], + data['change']['branch'], data['change']['subject'], data['change']['url']) self.log.info('Compiled Message %s: %s' % (channel, msg)) @@ -232,8 +234,9 @@ class Gerrit(threading.Thread): if (approval['type'] == 'Verified' and approval['value'] == '2' and channel in self._channels_for('events', 'x-vrif-plus-2')): - msg = 'Verification of a change to %s succeeded: %s %s' % ( + msg = 'Verification of a change to %s %s succeeded: %s %s' % ( data['change']['project'], + data['change']['branch'], data['change']['subject'], data['change']['url']) self.log.info('Compiled Message %s: %s' % (channel, msg)) @@ -242,8 +245,9 @@ class Gerrit(threading.Thread): if (approval['type'] == 'Code-Review' and approval['value'] == '-2' and channel in self._channels_for('events', 'x-crvw-minus-2')): - msg = 'A change to %s has been rejected: %s %s' % ( + msg = 'A change to %s %s has been rejected: %s %s' % ( data['change']['project'], + data['change']['branch'], data['change']['subject'], data['change']['url']) self.log.info('Compiled Message %s: %s' % (channel, msg)) @@ -252,8 +256,9 @@ class Gerrit(threading.Thread): if (approval['type'] == 'Code-Review' and approval['value'] == '2' and channel in self._channels_for('events', 'x-crvw-plus-2')): - msg = 'A change to %s has been approved: %s %s' % ( + msg = 'A change to %s %s has been approved: %s %s' % ( data['change']['project'], + data['change']['branch'], data['change']['subject'], data['change']['url']) self.log.info('Compiled Message %s: %s' % (channel, msg)) diff --git a/gerritbot/tests/unit/test_bot.py b/gerritbot/tests/unit/test_bot.py index 7c251b3..f1d82c5 100644 --- a/gerritbot/tests/unit/test_bot.py +++ b/gerritbot/tests/unit/test_bot.py @@ -195,7 +195,7 @@ class GerritTestCase(testtools.TestCase): self.assertEqual(self.channel, message.channel) self.assertEqual( 'A comment has been added to ' - 'openstack/gerritbot: More unit tests ' + 'openstack/gerritbot master: More unit tests ' 'https://review.openstack.org/123456', message.msg) @@ -215,7 +215,7 @@ class GerritTestCase(testtools.TestCase): message = self.ircbot.messages[1] self.assertEqual(self.channel, message.channel) self.assertEqual( - 'Verification of a change to openstack/gerritbot failed: ' + 'Verification of a change to openstack/gerritbot master failed: ' 'More unit tests https://review.openstack.org/123456', message.msg)