diff options
author | Konstantin Ryabitsev <konstantin@linuxfoundation.org> | 2018-12-13 09:45:08 -0500 |
---|---|---|
committer | Konstantin Ryabitsev <konstantin@linuxfoundation.org> | 2018-12-13 09:45:08 -0500 |
commit | f4eec4bd634daae41b58dfabf30e6883e311c039 (patch) | |
tree | fca9602fa9017b21cb4e591798ba41c6eef5215a | |
parent | 3664ad3d71fe74d7e737f57a7fd55fbec947472d (diff) | |
download | korg-helpers-f4eec4bd634daae41b58dfabf30e6883e311c039.tar.gz |
Use X-Patchwork-Bot: notify header logic
Some people don't want to litter their cc's with notify@kernel.org, so
let them set a special header instead.
Signed-off-by: Konstantin Ryabitsev <konstantin@linuxfoundation.org>
-rwxr-xr-x | git-patchwork-bot.py | 63 |
1 files changed, 34 insertions, 29 deletions
diff --git a/git-patchwork-bot.py b/git-patchwork-bot.py index 5663034..2fd87fb 100755 --- a/git-patchwork-bot.py +++ b/git-patchwork-bot.py @@ -37,9 +37,7 @@ from email.mime.text import MIMEText from email.header import Header from email.utils import formatdate, getaddresses -# Send all email 8-bit, this is not 1999 -from email import charset -charset.add_charset('utf-8', charset.SHORTEST, '8bit') +from fcntl import lockf, LOCK_EX, LOCK_NB try: import xmlrpclib @@ -47,7 +45,9 @@ except ImportError: # Python 3 has merged/renamed things. import xmlrpc.client as xmlrpclib -from fcntl import lockf, LOCK_EX, LOCK_NB +# Send all email 8-bit, this is not 1999 +from email import charset +charset.add_charset('utf-8', charset.SHORTEST, '8bit') DB_VERSION = 1 REST_API_VERSION = '1.1' @@ -580,32 +580,37 @@ def notify_submitters(rm, serieslist, refname, config, revs, nomail): logger.debug('Skipping neverto address:%s', submitter.get('email')) continue - ccs = [] - cchdr = headers.get('Cc') - if not cchdr: - cchdr = headers.get('cc') - if cchdr: - ccs = [chunk[1] for chunk in getaddresses([cchdr])] - - if 'onlyifcc' in config: - match = None - for chunk in config['onlyifcc'].split(','): - if chunk.strip() in ccs: - match = chunk - break - if match is None: - logger.debug('Skipping %s due to onlyifcc=%s', submitter.get('email'), config['onlyifcc']) - continue + xpb = headers.get('X-Patchwork-Bot') + logger.debug('X-Patchwork-Bot=%s', xpb) + # If X-Patchwork-Bot header is set to "notify" we always notify + if xpb != 'notify': + # Use cc-based notification logic + ccs = [] + cchdr = headers.get('Cc') + if not cchdr: + cchdr = headers.get('cc') + if cchdr: + ccs = [chunk[1] for chunk in getaddresses([cchdr])] + + if 'onlyifcc' in config: + match = None + for chunk in config['onlyifcc'].split(','): + if chunk.strip() in ccs: + match = chunk + break + if match is None: + logger.debug('Skipping %s due to onlyifcc=%s', submitter.get('email'), config['onlyifcc']) + continue - if ccs and 'neverifcc' in config: - match = None - for chunk in config['neverifcc'].split(','): - if chunk.strip() in ccs: - match = chunk - break - if match is not None: - logger.debug('Skipping %s due to neverifcc=%s', submitter.get('email'), config['neverifcc']) - continue + if ccs and 'neverifcc' in config: + match = None + for chunk in config['neverifcc'].split(','): + if chunk.strip() in ccs: + match = chunk + break + if match is not None: + logger.debug('Skipping %s due to neverifcc=%s', submitter.get('email'), config['neverifcc']) + continue logger.debug('Preparing a notification for %s', submitter.get('email')) body = ( |