From d884c4d8fd0a990d0746c7964bfd979a625c7ab2 Mon Sep 17 00:00:00 2001 From: Catalin Marinas Date: Fri, 27 Oct 2006 21:20:27 +0100 Subject: [PATCH] Add the 'autobcc' config option Useful to automatically bcc the e-mails to a given address. Signed-off-by: Catalin Marinas --- examples/stgitrc | 3 +++ stgit/commands/mail.py | 19 +++++++++++++++++-- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/examples/stgitrc b/examples/stgitrc index 2b85c1f..74c54c4 100644 --- a/examples/stgitrc +++ b/examples/stgitrc @@ -9,6 +9,9 @@ #commname: Your Name #commemail: your.name@yourcompany.com +# Automatically Bcc the address below +#autobcc: your.name@yourcompany.com + # Set to 'yes' if you don't want to use the 'resolved' command. # 'refresh' will automatically mark the conflicts as resolved #autoresolved: no diff --git a/stgit/commands/mail.py b/stgit/commands/mail.py index e4ee399..4864660 100644 --- a/stgit/commands/mail.py +++ b/stgit/commands/mail.py @@ -196,7 +196,15 @@ def __build_address_headers(tmpl, options, extra_cc = []): template. """ def csv(lst): - return reduce(lambda x, y: x + ', ' + y, lst) + s = '' + for i in lst: + if not i: + continue + if s: + s += ', ' + i + else: + s = i + return s def replace_header(header, addr, tmpl): r = re.compile('^' + header + ':\s+.+$', re.I | re.M) @@ -213,6 +221,11 @@ def __build_address_headers(tmpl, options, extra_cc = []): cc_addr = '' bcc_addr = '' + if config.has_option('stgit', 'autobcc'): + autobcc = config.get('stgit', 'autobcc') + else: + autobcc = '' + if options.to: to_addr = csv(options.to) if options.cc: @@ -220,7 +233,9 @@ def __build_address_headers(tmpl, options, extra_cc = []): elif extra_cc: cc_addr = csv(extra_cc) if options.bcc: - bcc_addr = csv(options.bcc) + bcc_addr = csv(options.bcc + [autobcc]) + elif autobcc: + bcc_addr = autobcc # replace existing headers if to_addr: -- 2.11.0