scripts: rfr: support multiple recipients

Add an argument (-t, --to) to specify additional recipients for the
review email. Sometimes it's useful to highlight some people explicitly
or in addition to the usual nvgpu core list.

In the future, we might consider adding some heuristics for less typing
(such as adding @nvidia.com automatically). For now the addresses have
to be complete.

Change-Id: I0e4ce5974a7a2f3db6eacc7128b825d20d6fd57c
Signed-off-by: Konsta Holtta <kholtta@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/1768066
GVS: Gerrit_Virtual_Submit
Reviewed-by: Alex Waterman <alexw@nvidia.com>
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
This commit is contained in:
Konsta Holtta
2018-08-21 11:18:03 +03:00
committed by mobile promotions
parent fec299954f
commit bf8a1e0019

View File

@@ -5,7 +5,6 @@
import os
import re
import sys
import json
import argparse
import tempfile
@@ -63,6 +62,9 @@ Otherwise it's treated as a git commit ID.
help='Specify the email\'s subject.')
parser.add_argument('-R', '--sender', action='store', default=None,
help='Specify a special from: email address.')
parser.add_argument('-t', '--to', action='append', default=[],
help='Specify an additional To: email address. '
'Can be repeated (-t a -t b).')
# Positionals: the gerrit URLs.
parser.add_argument('commits', metavar='Commit-IDs',
@@ -277,13 +279,15 @@ def email_commits(commits_info, sender, subject, args):
else:
msg = MIMEText(body)
msg['To'] = to_addr
to_addrs = [to_addr] + args.to
msg['To'] = ", ".join(to_addrs)
msg['From'] = sender
msg['Subject'] = subject
s = smtplib.SMTP('mail.nvidia.com')
s.sendmail(sender,
[to_addr],
to_addrs,
msg.as_string())
s.quit()