gerrit: provide option to suppress emails on some operations
When cherry picking large stacks of patches into branches, gerrit
generates emails on every operation along the way: ready, verify,
review, This results in tons of noise of which the recipients usually
do not care about.
This patch adds a command line option which allows to suppress sending
emails on ready, review, trybotready, and verify gerrit operations.
BUG=none
TEST=using the new command line option modified the 'verified' flag of
an existing gerit patch. Observed that emails are not generated
when --ne s passed in as a command line argument, and are
generated in case --ne is not present.
Change-Id: I15a3ad15e4acdec294a0606a999ca7f7b3bcf5be
Signed-off-by: Vadim Bendebury <vbendeb@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/1464365
Reviewed-by: Mike Frysinger <vapier@chromium.org>
diff --git a/scripts/gerrit.py b/scripts/gerrit.py
index 0b742de..aa64791 100644
--- a/scripts/gerrit.py
+++ b/scripts/gerrit.py
@@ -341,7 +341,8 @@
num = args[-1]
for arg in args[:-1]:
helper, cl = GetGerrit(opts, arg)
- helper.SetReview(cl, labels={'Code-Review': num}, dryrun=opts.dryrun)
+ helper.SetReview(cl, labels={'Code-Review': num},
+ dryrun=opts.dryrun, notify=opts.notify)
UserActReview.arg_min = 2
@@ -350,7 +351,8 @@
num = args[-1]
for arg in args[:-1]:
helper, cl = GetGerrit(opts, arg)
- helper.SetReview(cl, labels={'Verified': num}, dryrun=opts.dryrun)
+ helper.SetReview(cl, labels={'Verified': num},
+ dryrun=opts.dryrun, notify=opts.notify)
UserActVerify.arg_min = 2
@@ -359,7 +361,8 @@
num = args[-1]
for arg in args[:-1]:
helper, cl = GetGerrit(opts, arg)
- helper.SetReview(cl, labels={'Commit-Queue': num}, dryrun=opts.dryrun)
+ helper.SetReview(cl, labels={'Commit-Queue': num},
+ dryrun=opts.dryrun, notify=opts.notify)
UserActReady.arg_min = 2
@@ -368,7 +371,8 @@
num = args[-1]
for arg in args[:-1]:
helper, cl = GetGerrit(opts, arg)
- helper.SetReview(cl, labels={'Trybot-Ready': num}, dryrun=opts.dryrun)
+ helper.SetReview(cl, labels={'Trybot-Ready': num},
+ dryrun=opts.dryrun, notify=opts.notify)
UserActTrybotready.arg_min = 2
@@ -536,6 +540,10 @@
parser.add_argument('-n', '--dry-run', default=False, action='store_true',
dest='dryrun',
help='Show what would be done, but do not make changes')
+ parser.add_argument('--ne', '--no-emails', default=True, action='store_false',
+ dest='send_email',
+ help='Do not send email for some operations '
+ '(e.g. ready/review/trybotready/verify)')
parser.add_argument('-v', '--verbose', default=False, action='store_true',
help='Be more verbose in output')
parser.add_argument('-b', '--branch',
@@ -558,6 +566,9 @@
# A cache of gerrit helpers we'll load on demand.
opts.gerrit = {}
+
+ # Convert user friendly command line option into a gerrit parameter.
+ opts.notify = 'ALL' if opts.send_email else 'NONE'
opts.Freeze()
# pylint: disable=global-statement