Commit b0fb8d57 authored by Thiago Perrotta's avatar Thiago Perrotta Committed by LUCI CQ

Introduce --send-email flag as an alias to --send-mail for `git cl upload`

Vanilla git has a git-send-email(1) subcommand. `git cl upload` should
follow suit by using the same flag name to be consistent and avoid
confusion.

[1]: https://git-scm.com/docs/git-send-email

Bug: none
Change-Id: I47ff8e03bd11915e99804fe1695046d874efc4e0
Tested: `git cl upload --send-email` to upload this very own CL
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/3854330Reviewed-by: 's avatarAravind Vasudevan <aravindvasudev@google.com>
Commit-Queue: Aravind Vasudevan <aravindvasudev@google.com>
Auto-Submit: Thiago Perrotta <tperrotta@chromium.org>
parent 8d2f7740
...@@ -2508,8 +2508,8 @@ class Changelist(object): ...@@ -2508,8 +2508,8 @@ class Changelist(object):
refspec_opts = [] refspec_opts = []
# By default, new changes are started in WIP mode, and subsequent patchsets # By default, new changes are started in WIP mode, and subsequent patchsets
# don't send email. At any time, passing --send-mail will mark the change # don't send email. At any time, passing --send-mail or --send-email will
# ready and send email for that particular patch. # mark the change ready and send email for that particular patch.
if options.send_mail: if options.send_mail:
refspec_opts.append('ready') refspec_opts.append('ready')
refspec_opts.append('notify=ALL') refspec_opts.append('notify=ALL')
...@@ -2518,8 +2518,9 @@ class Changelist(object): ...@@ -2518,8 +2518,9 @@ class Changelist(object):
else: else:
refspec_opts.append('notify=NONE') refspec_opts.append('notify=NONE')
# TODO(tandrii): options.message should be posted as a comment # TODO(tandrii): options.message should be posted as a comment if
# if --send-mail is set on non-initial upload as Rietveld used to do it. # --send-mail or --send-email is set on non-initial upload as Rietveld used
# to do it.
# Set options.title in case user was prompted in _GetTitleForUpload and # Set options.title in case user was prompted in _GetTitleForUpload and
# _CMDUploadChange needs to be called again. # _CMDUploadChange needs to be called again.
...@@ -2609,11 +2610,11 @@ class Changelist(object): ...@@ -2609,11 +2610,11 @@ class Changelist(object):
if self.GetIssue() and (reviewers or cc): if self.GetIssue() and (reviewers or cc):
# GetIssue() is not set in case of non-squash uploads according to tests. # GetIssue() is not set in case of non-squash uploads according to tests.
# TODO(crbug.com/751901): non-squash uploads in git cl should be removed. # TODO(crbug.com/751901): non-squash uploads in git cl should be removed.
gerrit_util.AddReviewers( gerrit_util.AddReviewers(self.GetGerritHost(),
self.GetGerritHost(), self._GerritChangeIdentifier(),
self._GerritChangeIdentifier(), reviewers,
reviewers, cc, cc,
notify=bool(options.send_mail)) notify=bool(options.send_mail))
return 0 return 0
...@@ -4313,7 +4314,11 @@ def CMDupload(parser, args): ...@@ -4313,7 +4314,11 @@ def CMDupload(parser, args):
action='append', default=[], action='append', default=[],
help=('Gerrit hashtag for new CL; ' help=('Gerrit hashtag for new CL; '
'can be applied multiple times')) 'can be applied multiple times'))
parser.add_option('-s', '--send-mail', action='store_true', parser.add_option('-s',
'--send-mail',
'--send-email',
dest='send_mail',
action='store_true',
help='send email to reviewer(s) and cc(s) immediately') help='send email to reviewer(s) and cc(s) immediately')
parser.add_option('--target_branch', parser.add_option('--target_branch',
'--target-branch', '--target-branch',
...@@ -4330,10 +4335,12 @@ def CMDupload(parser, args): ...@@ -4330,10 +4335,12 @@ def CMDupload(parser, args):
const='TBR', help='add a set of OWNERS to TBR') const='TBR', help='add a set of OWNERS to TBR')
parser.add_option('--r-owners', dest='add_owners_to', action='store_const', parser.add_option('--r-owners', dest='add_owners_to', action='store_const',
const='R', help='add a set of OWNERS to R') const='R', help='add a set of OWNERS to R')
parser.add_option('-c', '--use-commit-queue', action='store_true', parser.add_option('-c',
'--use-commit-queue',
action='store_true',
default=False, default=False,
help='tell the CQ to commit this patchset; ' help='tell the CQ to commit this patchset; '
'implies --send-mail') 'implies --send-mail')
parser.add_option('-d', '--cq-dry-run', parser.add_option('-d', '--cq-dry-run',
action='store_true', default=False, action='store_true', default=False,
help='Send the patchset to do a CQ dry run right after ' help='Send the patchset to do a CQ dry run right after '
......
...@@ -1315,6 +1315,18 @@ class TestGitCl(unittest.TestCase): ...@@ -1315,6 +1315,18 @@ class TestGitCl(unittest.TestCase):
final_description=( final_description=(
'desc ✔\n\nBUG=\nR=foo@example.com\n\nChange-Id: I123456789')) 'desc ✔\n\nBUG=\nR=foo@example.com\n\nChange-Id: I123456789'))
def test_gerrit_reviewers_cmd_line_send_email(self):
self._run_gerrit_upload_test(
['-r', 'foo@example.com', '--send-email'],
'desc ✔\n\nBUG=\n\nChange-Id: I123456789',
reviewers=['foo@example.com'],
squash=False,
squash_mode='override_nosquash',
notify=True,
change_id='I123456789',
final_description=(
'desc ✔\n\nBUG=\nR=foo@example.com\n\nChange-Id: I123456789'))
def test_gerrit_upload_force_sets_bug(self): def test_gerrit_upload_force_sets_bug(self):
self._run_gerrit_upload_test( self._run_gerrit_upload_test(
['-b', '10000', '-f'], ['-b', '10000', '-f'],
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment