From b0fb8d570df94ed4e457adaa827d1ce9b51ade00 Mon Sep 17 00:00:00 2001 From: Thiago Perrotta Date: Tue, 30 Aug 2022 21:26:19 +0000 Subject: [PATCH] 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/+/3854330 Reviewed-by: Aravind Vasudevan Commit-Queue: Aravind Vasudevan Auto-Submit: Thiago Perrotta --- git_cl.py | 31 +++++++++++++++++++------------ tests/git_cl_test.py | 12 ++++++++++++ 2 files changed, 31 insertions(+), 12 deletions(-) diff --git a/git_cl.py b/git_cl.py index 6725f4a5c..05714ef8a 100755 --- a/git_cl.py +++ b/git_cl.py @@ -2508,8 +2508,8 @@ class Changelist(object): refspec_opts = [] # 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 - # ready and send email for that particular patch. + # don't send email. At any time, passing --send-mail or --send-email will + # mark the change ready and send email for that particular patch. if options.send_mail: refspec_opts.append('ready') refspec_opts.append('notify=ALL') @@ -2518,8 +2518,9 @@ class Changelist(object): else: refspec_opts.append('notify=NONE') - # TODO(tandrii): options.message should be posted as a comment - # if --send-mail is set on non-initial upload as Rietveld used to do it. + # TODO(tandrii): options.message should be posted as a comment if + # --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 # _CMDUploadChange needs to be called again. @@ -2609,11 +2610,11 @@ class Changelist(object): if self.GetIssue() and (reviewers or cc): # 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. - gerrit_util.AddReviewers( - self.GetGerritHost(), - self._GerritChangeIdentifier(), - reviewers, cc, - notify=bool(options.send_mail)) + gerrit_util.AddReviewers(self.GetGerritHost(), + self._GerritChangeIdentifier(), + reviewers, + cc, + notify=bool(options.send_mail)) return 0 @@ -4313,7 +4314,11 @@ def CMDupload(parser, args): action='append', default=[], help=('Gerrit hashtag for new CL; ' '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') parser.add_option('--target_branch', '--target-branch', @@ -4330,10 +4335,12 @@ def CMDupload(parser, args): const='TBR', help='add a set of OWNERS to TBR') parser.add_option('--r-owners', dest='add_owners_to', action='store_const', 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, help='tell the CQ to commit this patchset; ' - 'implies --send-mail') + 'implies --send-mail') parser.add_option('-d', '--cq-dry-run', action='store_true', default=False, help='Send the patchset to do a CQ dry run right after ' diff --git a/tests/git_cl_test.py b/tests/git_cl_test.py index 0c72c274c..22f271649 100755 --- a/tests/git_cl_test.py +++ b/tests/git_cl_test.py @@ -1315,6 +1315,18 @@ class TestGitCl(unittest.TestCase): final_description=( '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): self._run_gerrit_upload_test( ['-b', '10000', '-f'],