Output comment and email filters in debugging.
Also, minor optimization to email filter matching. Change-Id: Iedea0fc14b10a8f68ec52e38ceab4b2fb407e364 Reviewed-on: https://review.openstack.org/18515 Reviewed-by: Antoine Musso <hashar@free.fr> Reviewed-by: Monty Taylor <mordred@inaugust.com> Approved: James E. Blair <corvus@inaugust.com> Tested-by: Jenkins
This commit is contained in:
parent
71e9412d9c
commit
cf429f325d
|
@ -622,6 +622,8 @@ class EventFilter(object):
|
||||||
self._types = types
|
self._types = types
|
||||||
self._branches = branches
|
self._branches = branches
|
||||||
self._refs = refs
|
self._refs = refs
|
||||||
|
self._comment_filters = comment_filters
|
||||||
|
self._email_filters = email_filters
|
||||||
self.types = [re.compile(x) for x in types]
|
self.types = [re.compile(x) for x in types]
|
||||||
self.branches = [re.compile(x) for x in branches]
|
self.branches = [re.compile(x) for x in branches]
|
||||||
self.refs = [re.compile(x) for x in refs]
|
self.refs = [re.compile(x) for x in refs]
|
||||||
|
@ -641,6 +643,10 @@ class EventFilter(object):
|
||||||
if self.approvals:
|
if self.approvals:
|
||||||
ret += ' approvals: %s' % ', '.join(
|
ret += ' approvals: %s' % ', '.join(
|
||||||
['%s:%s' % a for a in self.approvals.items()])
|
['%s:%s' % a for a in self.approvals.items()])
|
||||||
|
if self._comment_filters:
|
||||||
|
ret += ' comment_filters: %s' % ', '.join(self._comment_filters)
|
||||||
|
if self._email_filters:
|
||||||
|
ret += ' email_filters: %s' % ', '.join(self._email_filters)
|
||||||
ret += '>'
|
ret += '>'
|
||||||
|
|
||||||
return ret
|
return ret
|
||||||
|
@ -678,7 +684,7 @@ class EventFilter(object):
|
||||||
matches_comment_filter = False
|
matches_comment_filter = False
|
||||||
for comment_filter in self.comment_filters:
|
for comment_filter in self.comment_filters:
|
||||||
if (event.comment is not None and
|
if (event.comment is not None and
|
||||||
comment_filter.search(event.comment)):
|
comment_filter.search(event.comment)):
|
||||||
matches_comment_filter = True
|
matches_comment_filter = True
|
||||||
if self.comment_filters and not matches_comment_filter:
|
if self.comment_filters and not matches_comment_filter:
|
||||||
return False
|
return False
|
||||||
|
@ -686,12 +692,12 @@ class EventFilter(object):
|
||||||
# We better have an account provided by Gerrit to do
|
# We better have an account provided by Gerrit to do
|
||||||
# email filtering.
|
# email filtering.
|
||||||
if event.account is not None:
|
if event.account is not None:
|
||||||
|
account_email = event.account.get('email')
|
||||||
# email_filters are ORed
|
# email_filters are ORed
|
||||||
matches_email_filter = False
|
matches_email_filter = False
|
||||||
for email_filter in self.email_filters:
|
for email_filter in self.email_filters:
|
||||||
account_email = event.account.get('email')
|
|
||||||
if (account_email is not None and
|
if (account_email is not None and
|
||||||
email_filter.search(account_email)):
|
email_filter.search(account_email)):
|
||||||
matches_email_filter = True
|
matches_email_filter = True
|
||||||
if self.email_filters and not matches_email_filter:
|
if self.email_filters and not matches_email_filter:
|
||||||
return False
|
return False
|
||||||
|
|
Loading…
Reference in New Issue