Add option for git-repo to support 'silent' uploads

When --ne/--no-emails is added to 'repo upload' command line, gerrit
server will not generate notification emails.

project.py:Project.UploadForReview method is modified to accept a
string recognizable by gerrit to indicate different sets of destination
email addressees, but the upload command line allows only one option -
disable sending emails completely.

Default repo upload behavior is not being changed.

TEST=tried in the Chrome OS repo, observed that patches uploaded with
     --ne or --no-emails indeed do not trigger any emails, while
     patches uploaded without these command line options still trigger
     email notifications.

Change-Id: I0301edec984907aedac277d883bd0e6d3099aedc
This commit is contained in:
Vadim Bendebury 2018-10-31 13:48:01 -07:00 committed by Vadim Bendebury
parent 713c5872fb
commit bd8f658823
2 changed files with 9 additions and 0 deletions

View File

@ -176,6 +176,7 @@ class ReviewableBranch(object):
auto_topic=False, auto_topic=False,
draft=False, draft=False,
private=False, private=False,
notify=None,
wip=False, wip=False,
dest_branch=None, dest_branch=None,
validate_certs=True, validate_certs=True,
@ -185,6 +186,7 @@ class ReviewableBranch(object):
auto_topic=auto_topic, auto_topic=auto_topic,
draft=draft, draft=draft,
private=private, private=private,
notify=notify,
wip=wip, wip=wip,
dest_branch=dest_branch, dest_branch=dest_branch,
validate_certs=validate_certs, validate_certs=validate_certs,
@ -1118,6 +1120,7 @@ class Project(object):
auto_topic=False, auto_topic=False,
draft=False, draft=False,
private=False, private=False,
notify=None,
wip=False, wip=False,
dest_branch=None, dest_branch=None,
validate_certs=True, validate_certs=True,
@ -1174,6 +1177,8 @@ class Project(object):
opts = ['r=%s' % p for p in people[0]] opts = ['r=%s' % p for p in people[0]]
opts += ['cc=%s' % p for p in people[1]] opts += ['cc=%s' % p for p in people[1]]
if notify:
opts += ['notify=' + notify]
if private: if private:
opts += ['private'] opts += ['private']
if wip: if wip:

View File

@ -150,6 +150,9 @@ Gerrit Code Review: https://www.gerritcodereview.com/
p.add_option('-d', '--draft', p.add_option('-d', '--draft',
action='store_true', dest='draft', default=False, action='store_true', dest='draft', default=False,
help='If specified, upload as a draft.') help='If specified, upload as a draft.')
p.add_option('--ne', '--no-emails',
action='store_false', dest='notify', default=True,
help='If specified, do not send emails on upload.')
p.add_option('-p', '--private', p.add_option('-p', '--private',
action='store_true', dest='private', default=False, action='store_true', dest='private', default=False,
help='If specified, upload as a private change.') help='If specified, upload as a private change.')
@ -391,6 +394,7 @@ Gerrit Code Review: https://www.gerritcodereview.com/
auto_topic=opt.auto_topic, auto_topic=opt.auto_topic,
draft=opt.draft, draft=opt.draft,
private=opt.private, private=opt.private,
notify=None if opt.notify else 'NONE',
wip=opt.wip, wip=opt.wip,
dest_branch=destination, dest_branch=destination,
validate_certs=opt.validate_certs, validate_certs=opt.validate_certs,