diff options
author | Konstantin Ryabitsev <konstantin@linuxfoundation.org> | 2023-12-22 15:26:06 -0500 |
---|---|---|
committer | Konstantin Ryabitsev <konstantin@linuxfoundation.org> | 2023-12-22 15:36:45 -0500 |
commit | 4e03211130d5afbf26297bee8b549013fc30e6fc (patch) | |
tree | 5a2814ba36639871bd5482179af9cf87ace02be2 | |
parent | 28563f0550dd7ef36f1a933b36fe787e710f9a52 (diff) | |
download | b4-4e03211130d5afbf26297bee8b549013fc30e6fc.tar.gz |
ez: implement send --dry-run-to
Sometimes it is useful to be able to send the series out to someone for
a quick one-over review (e.g. to your mentor, boss, colleague) before
actually sending it out to the actual maintainers.
It is now possible to do so with:
b4 send --dry-run-to addr@example.com
This will not trigger a tag-and-reroll and will include a DRYRUN into
the patch prefixes to clearly indicate that it's not the final
submission that should be used for review.
Suggested-by: Marcos Paulo de Souza <mpdesouza@suse.com>
Link: https://lore.kernel.org/f5c38763b4d42cfafdaac24d83ec18b81dfc073a.camel@suse.com
Closes: https://bugzilla.kernel.org/show_bug.cgi?id=218302
Signed-off-by: Konstantin Ryabitsev <konstantin@linuxfoundation.org>
-rw-r--r-- | b4/command.py | 20 | ||||
-rw-r--r-- | b4/ez.py | 62 | ||||
-rw-r--r-- | man/b4.5 | 15 | ||||
-rw-r--r-- | man/b4.5.rst | 13 |
4 files changed, 74 insertions, 36 deletions
diff --git a/b4/command.py b/b4/command.py index 091fbf5..d104637 100644 --- a/b4/command.py +++ b/b4/command.py @@ -310,16 +310,20 @@ def setup_parser() -> argparse.ArgumentParser: # b4 send sp_send = subparsers.add_parser('send', help='Submit your work for review on the mailing lists') - sp_send.add_argument('-d', '--dry-run', dest='dryrun', action='store_true', default=False, - help='Do not send, just dump out raw smtp messages to the stdout') - sp_send.add_argument('-o', '--output-dir', - help='Do not send, write raw messages to this directory (forces --dry-run)') - sp_send.add_argument('--reflect', action='store_true', default=False, - help='Send everything to yourself instead of the actual recipients') + sp_send_g = sp_send.add_mutually_exclusive_group() + sp_send_g.add_argument('-d', '--dry-run', dest='dryrun', action='store_true', default=False, + help='Do not send, just dump out raw smtp messages to the stdout') + sp_send_g.add_argument('-o', '--output-dir', + help='Do not send, write raw messages to this directory (forces --dry-run)') + sp_send_g.add_argument('--dry-run-to', nargs='+', metavar='ADDR', + help='Like --dry-run, but sends out via email to specified recipients') + sp_send_g.add_argument('--reflect', action='store_true', default=False, + help='Send everything to yourself instead of the actual recipients') + sp_send.add_argument('--no-trailer-to-cc', action='store_true', default=False, help='Do not add any addresses found in the cover or patch trailers to To: or Cc:') - sp_send.add_argument('--to', nargs='+', help='Addresses to add to the To: list') - sp_send.add_argument('--cc', nargs='+', help='Addresses to add to the Cc: list') + sp_send.add_argument('--to', nargs='+', metavar='ADDR', help='Addresses to add to the To: list') + sp_send.add_argument('--cc', nargs='+', metavar='ADDR', help='Addresses to add to the Cc: list') sp_send.add_argument('--not-me-too', action='store_true', default=False, help='Remove yourself from the To: or Cc: list') sp_send.add_argument('--resend', metavar='vN', nargs='?', const='latest', @@ -1170,11 +1170,14 @@ def get_mailfrom() -> Tuple[str, str]: return usercfg.get('name'), usercfg.get('email') -def get_prep_branch_as_patches(movefrom: bool = True, thread: bool = True, addtracking: bool = True +def get_prep_branch_as_patches(movefrom: bool = True, thread: bool = True, addtracking: bool = True, + prefixes: Optional[List[str]] = None ) -> Tuple[List, List, str, List[Tuple[str, email.message.Message]]]: cover, tracking = load_cover(strip_comments=True) - prefixes = tracking['series'].get('prefixes', list()) + if prefixes is None: + prefixes = list() + prefixes += tracking['series'].get('prefixes', list()) start_commit = get_series_start() change_id = tracking['series'].get('change-id') revision = tracking['series'].get('revision') @@ -1356,8 +1359,13 @@ def cmd_send(cmdargs: argparse.Namespace) -> None: logger.critical(' Stash or commit them first.') sys.exit(1) + if cmdargs.dry_run_to: + prefixes = ['DRYRUN'] + else: + prefixes = None + try: - todests, ccdests, tag_msg, patches = get_prep_branch_as_patches() + todests, ccdests, tag_msg, patches = get_prep_branch_as_patches(prefixes=prefixes) except RuntimeError as ex: logger.critical('CRITICAL: Failed to convert range to patches: %s', ex) sys.exit(1) @@ -1379,7 +1387,7 @@ def cmd_send(cmdargs: argparse.Namespace) -> None: excludes = set() pccs = dict() - if cmdargs.no_trailer_to_cc: + if cmdargs.dry_run_to or cmdargs.no_trailer_to_cc: todests = list() ccdests = list() else: @@ -1413,27 +1421,30 @@ def cmd_send(cmdargs: argparse.Namespace) -> None: excludes.add(myemail) tos = set() - if cmdargs.to: - tos.update(cmdargs.to) - if config.get('send-series-to'): - tos.add(config.get('send-series-to')) - if tos: - for pair in utils.getaddresses(list(tos)): - if pair[1] in seen: - continue - seen.add(pair[1]) - todests.append(pair) ccs = set() - if cmdargs.cc: - ccs.update(cmdargs.cc) - if config.get('send-series-cc'): - ccs.add(config.get('send-series-cc')) + if cmdargs.dry_run_to: + tos.update(cmdargs.dry_run_to) + else: + if cmdargs.to: + tos.update(cmdargs.to) + if config.get('send-series-to'): + tos.add(config.get('send-series-to')) + if cmdargs.cc: + ccs.update(cmdargs.cc) + if config.get('send-series-cc'): + ccs.add(config.get('send-series-cc')) if ccs: for pair in utils.getaddresses(list(ccs)): if pair[1] in seen: continue seen.add(pair[1]) ccdests.append(pair) + if tos: + for pair in utils.getaddresses(list(tos)): + if pair[1] in seen: + continue + seen.add(pair[1]) + todests.append(pair) allto = list() allcc = list() @@ -1447,7 +1458,8 @@ def cmd_send(cmdargs: argparse.Namespace) -> None: alldests.update(set([x[1] for x in allcc])) if not len(alldests): - logger.critical('CRITICAL: Could not find any destination addresses (try: b4 prep --auto-to-cc).') + logger.critical('CRITICAL: Could not find any destination addresses') + logger.critical(' try b4 prep --auto-to-cc or b4 send --to addr') sys.exit(1) if not len(allto): @@ -1474,6 +1486,11 @@ def cmd_send(cmdargs: argparse.Namespace) -> None: logger.debug('No sendemail configs found, will use the default web endpoint') endpoint = DEFAULT_ENDPOINT + # Cannot currently use endpoint with --dry-run-to + if endpoint and cmdargs.dry_run_to: + logger.critical('CRITICAL: cannot use the web endpoint with --dry-run-to') + sys.exit(1) + # Give the user the last opportunity to bail out if not cmdargs.dryrun: logger.info('---') @@ -1507,6 +1524,8 @@ def cmd_send(cmdargs: argparse.Namespace) -> None: fromaddr = sconfig.get('from') if cmdargs.reflect: logger.info(' - send the above messages to just %s (REFLECT MODE)', fromaddr) + elif cmdargs.dry_run_to: + logger.info(' - send the above messages to the DRY-RUN recipients listed') else: logger.info(' - send the above messages to actual listed recipients') logger.info(' - with envelope-from: %s', fromaddr) @@ -1528,7 +1547,7 @@ def cmd_send(cmdargs: argparse.Namespace) -> None: else: logger.info(' - via SMTP server %s', smtpserver) - if not (cmdargs.reflect or cmdargs.resend): + if not (cmdargs.reflect or cmdargs.resend or cmdargs.dry_run_to): logger.info(' - tag and reroll the series to the next revision') logger.info('') if cmdargs.reflect: @@ -1645,6 +1664,9 @@ def cmd_send(cmdargs: argparse.Namespace) -> None: if cmdargs.resend: logger.debug('Not updating cover/tracking on resend') return + if cmdargs.dry_run_to: + logger.debug('Not updating cover/tracking on --dry-run-to') + return reroll(mybranch, tag_msg, cl_msgid) @@ -608,7 +608,7 @@ Enroll current branch, using the passed tag, branch, or commit as fork base .INDENT 0.0 .TP .B usage: -b4 send [\-h] [\-d] [\-o OUTPUT_DIR] [\-\-reflect] [\-\-no\-trailer\-to\-cc] [\-\-to TO [TO ...]] [\-\-cc CC [CC ...]] [\-\-not\-me\-too] [\-\-resend [RESEND]] [\-\-no\-sign] [\-\-web\-auth\-new] [\-\-web\-auth\-verify VERIFY_TOKEN] +b4 send [\-h] [\-d | \-o OUTPUT_DIR | \-\-dry\-run\-to ADDR [ADDR ...] | \-\-reflect] [\-\-no\-trailer\-to\-cc] [\-\-to ADDR [ADDR ...]] [\-\-cc ADDR [ADDR ...]] [\-\-not\-me\-too] [\-\-resend [vN]] [\-\-no\-sign] [\-\-web\-auth\-new] [\-\-web\-auth\-verify VERIFY_TOKEN] .TP .B options: .INDENT 7.0 @@ -618,6 +618,13 @@ show this help message and exit .TP .B \-d\fP,\fB \-\-dry\-run Do not send, just dump out raw smtp messages to the stdout +.UNINDENT +.INDENT 7.0 +.TP +.B \-\-dry\-run\-to ADDR [ADDR ...] +Like \-\-dry\-run, but sends out via email to specified recipients +.UNINDENT +.INDENT 7.0 .TP .BI \-o \ OUTPUT_DIR\fR,\fB \ \-\-output\-dir \ OUTPUT_DIR Do not send, write raw messages to this directory (forces \-\-dry\-run) @@ -630,10 +637,10 @@ Do not add any addresses found in the cover or patch trailers to To: or Cc: .UNINDENT .INDENT 7.0 .TP -.B \-\-to TO [TO ...] +.B \-\-to ADDR [ADDR ...] Addresses to add to the To: list .TP -.B \-\-cc CC [CC ...] +.B \-\-cc ADDR [ADDR ...] Addresses to add to the Cc: list .UNINDENT .INDENT 7.0 @@ -643,7 +650,7 @@ Remove yourself from the To: or Cc: list .UNINDENT .INDENT 7.0 .TP -.B \-\-resend [RESEND] +.B \-\-resend [vN] Resend a previously sent version of the series .UNINDENT .INDENT 7.0 diff --git a/man/b4.5.rst b/man/b4.5.rst index d77acc4..3120687 100644 --- a/man/b4.5.rst +++ b/man/b4.5.rst @@ -393,11 +393,15 @@ Enroll existing branch: b4 send ~~~~~~~ usage: - b4 send [-h] [-d] [-o OUTPUT_DIR] [--reflect] [--no-trailer-to-cc] [--to TO [TO ...]] [--cc CC [CC ...]] [--not-me-too] [--resend [RESEND]] [--no-sign] [--web-auth-new] [--web-auth-verify VERIFY_TOKEN] + b4 send [-h] [-d | -o OUTPUT_DIR | --dry-run-to ADDR [ADDR ...] | --reflect] [--no-trailer-to-cc] [--to ADDR [ADDR ...]] [--cc ADDR [ADDR ...]] [--not-me-too] [--resend [vN]] [--no-sign] [--web-auth-new] [--web-auth-verify VERIFY_TOKEN] options: -h, --help show this help message and exit -d, --dry-run Do not send, just dump out raw smtp messages to the stdout + + --dry-run-to ADDR [ADDR ...] + Like --dry-run, but sends out via email to specified recipients + -o OUTPUT_DIR, --output-dir OUTPUT_DIR Do not send, write raw messages to this directory (forces --dry-run) @@ -407,15 +411,16 @@ options: --no-trailer-to-cc Do not add any addresses found in the cover or patch trailers to To: or Cc: - --to TO [TO ...] + --to ADDR [ADDR ...] Addresses to add to the To: list - --cc CC [CC ...] + + --cc ADDR [ADDR ...] Addresses to add to the Cc: list --not-me-too Remove yourself from the To: or Cc: list - --resend [RESEND] + --resend [vN] Resend a previously sent version of the series --no-sign |