Skip notifications about WIP changes
WIP changes are likely to spam irc channels as they are not even visible by default in dashboards. If we detect the WIP flag as present and set to true, we just skip doing anything about that message. Change-Id: Id4ee6c825e6d508c0c722d01ac8b1147b4025dbe
This commit is contained in:
parent
cfcc7d53b3
commit
54e2f218d6
|
@ -301,9 +301,15 @@ class Gerrit(threading.Thread):
|
|||
return ret
|
||||
|
||||
def _read(self, data):
|
||||
# We skip notifications abour WIP changes
|
||||
if 'change' in data and data['change'].get('wip', False):
|
||||
self.log.debug('Skipped processing event on WIP change: %s', data)
|
||||
return
|
||||
try:
|
||||
# We only consider event (not project/branch) filters for these.
|
||||
event_only_types = ('ref-updated',)
|
||||
# 'wip-state-changed' is included in order to notify when a change
|
||||
# moves from wip to non-wip.
|
||||
event_only_types = ('ref-updated', 'wip-state-changed')
|
||||
if data['type'] in event_only_types:
|
||||
channel_set = self._channels_for('events', data['type'])
|
||||
else:
|
||||
|
|
|
@ -12,6 +12,7 @@
|
|||
# under the License.
|
||||
|
||||
import collections
|
||||
import copy
|
||||
|
||||
import testtools
|
||||
import yaml
|
||||
|
@ -139,6 +140,9 @@ class GerritTestCase(testtools.TestCase):
|
|||
|
||||
}
|
||||
|
||||
self.sample_data_wip = copy.deepcopy(self.sample_data)
|
||||
self.sample_data_wip['change']['wip'] = True
|
||||
|
||||
def _validate_patchset_created(self):
|
||||
self.assertEqual(1, len(self.ircbot.messages))
|
||||
message = self.ircbot.messages[0]
|
||||
|
@ -171,6 +175,10 @@ class GerritTestCase(testtools.TestCase):
|
|||
self.gerrit._read(dict(self.sample_data, type='ref-updated'))
|
||||
self._validate_ref_updated()
|
||||
|
||||
def test__read_ref_updated_wip(self):
|
||||
self.gerrit._read(dict(self.sample_data_wip, type='ref-updated'))
|
||||
self.assertEqual(0, len(self.ircbot.messages))
|
||||
|
||||
def _validate_change_merged(self):
|
||||
self.assertEqual(1, len(self.ircbot.messages))
|
||||
message = self.ircbot.messages[0]
|
||||
|
|
10
tox.ini
10
tox.ini
|
@ -1,5 +1,8 @@
|
|||
[tox]
|
||||
envlist = py37,pep8
|
||||
envlist =
|
||||
pep8
|
||||
py3
|
||||
py3-{devel}
|
||||
|
||||
[testenv]
|
||||
usedevelop = True
|
||||
|
@ -11,7 +14,10 @@ setenv = VIRTUAL_ENV={envdir}
|
|||
LC_ALL=en_US.UTF-8
|
||||
PYTHONWARNINGS=default::DeprecationWarning
|
||||
TESTS_DIR=./gerritbot/tests/unit/
|
||||
deps = -r{toxinidir}/test-requirements.txt
|
||||
deps =
|
||||
-r{toxinidir}/test-requirements.txt
|
||||
devel: git+https://opendev.org/opendev/gerritlib.git@master#egg=gerritlib
|
||||
|
||||
whitelist_externals = rm
|
||||
commands =
|
||||
rm -f .testrepository/times.dbm
|
||||
|
|
Loading…
Reference in New Issue