diff --git a/git-review.1 b/git-review.1 index ecad1ab4..4b653fb1 100644 --- a/git-review.1 +++ b/git-review.1 @@ -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 diff --git a/git_review/cmd.py b/git_review/cmd.py index 0bc7c219..ac5ba46c 100644 --- a/git_review/cmd.py +++ b/git_review/cmd.py @@ -1436,6 +1436,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", @@ -1704,6 +1708,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: diff --git a/git_review/tests/test_unit.py b/git_review/tests/test_unit.py index 87ff76f3..553cfac2 100644 --- a/git_review/tests/test_unit.py +++ b/git_review/tests/test_unit.py @@ -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): diff --git a/releasenotes/notes/user-notifications-0276f6c14d119225.yaml b/releasenotes/notes/user-notifications-0276f6c14d119225.yaml new file mode 100644 index 00000000..8503696c --- /dev/null +++ b/releasenotes/notes/user-notifications-0276f6c14d119225.yaml @@ -0,0 +1,5 @@ +--- +features: + - | + Added the ``--notify`` option, which can be used to ensure specified + receivers receives email notifications