Merge "Make it possible to specify who is notified"

This commit is contained in:
Zuul 2020-02-05 18:03:31 +00:00 committed by Gerrit Code Review
commit 1a58ace6cb
4 changed files with 29 additions and 0 deletions

View File

@ -42,6 +42,7 @@
.Op Fl r Ar remote
.Op Fl t Ar topic
.Op Fl \-reviewers Ar reviewer ...
.Op Fl \-notify Ar type
.Op Ar branch
.Nm
.Fl l
@ -152,6 +153,8 @@ If not specified, a bug number from the commit summary will be used. Alternative
Submit review without topic.
.It Fl \-reviewers Ar reviewer ...
Subscribe one or more reviewers to the uploaded patch sets. Reviewers should be identifiable by Gerrit (usually use their Gerrit username or email address).
.It Fl \-notify Ar type
Control to whom email notifications are sent. Possible values are NONE, OWNER, OWNER_REVIEWERS, ALL (the last one is the default).
.It Fl u , Fl \-update
Skip cached local copies and force updates from network resources.
.It Fl l , Fl \-list

View File

@ -1440,6 +1440,10 @@ review.
action="store_true",
help="Use remote push-url logic instead of separate"
" remotes")
parser.add_argument('--notify',
choices=['NONE', 'OWNER', 'OWNER_REVIEWERS', 'ALL'],
help="Control to whom email notifications are sent,"
" defaults to ALL.")
rebase_group = parser.add_mutually_exclusive_group()
rebase_group.add_argument("-R", "--no-rebase", dest="rebase",
@ -1702,6 +1706,9 @@ review.
if options.remove_private:
push_options.append('remove-private')
if options.notify is not None:
push_options.append("notify=%s" % options.notify)
if push_options:
cmd += "%" + ",".join(push_options)
if options.dry:

View File

@ -18,6 +18,7 @@
import argparse
import functools
import os
import sys
import textwrap
import fixtures
@ -365,6 +366,19 @@ class GitReviewUnitTest(testtools.TestCase):
self.assertRaises(Exception, cmd._main)
self.assertTrue(resolve_tracking.called)
@mock.patch('sys.argv', ['argv0', '-n', '--notify', 'OWNER'])
@mock.patch('git_review.cmd.check_remote')
@mock.patch('git_review.cmd.rebase_changes')
@mock.patch('git_review.cmd.set_hooks_commit_msg')
@mock.patch('git_review.cmd.assert_one_change')
@mock.patch('sys.stdout', io.StringIO())
@mock.patch('sys.exit')
def test_notify(self, check_remote, rebase, set_hooks, assert_one, exit):
cmd._main()
sys.stdout.seek(0)
stdout = sys.stdout.read()
self.assertIn("notify=OWNER", stdout)
class DownloadFlagUnitTest(testtools.TestCase):

View File

@ -0,0 +1,5 @@
---
features:
- |
Added the ``--notify`` option, which can be used to ensure specified
receivers receives email notifications