ty: Allow users to specify whether thank-yous are sent to themselves
PATCH v5 1/1 ty: Allow users to specify whether thank-yous are sent to themselves
The motivation behind this change was that thank-yous weren't showing up in maintainer's inboxes. This is a problem because some of us the presence of these mails to indicate that particular sets or individual patches have been applied or not.
Provide command line option '--me-too' to override the default behaviour. If this is not specified, there are no functional changes.
---
v4 -> v5: Actually test the conflict resolutions and repair the obvious breakage! *hangs head in shame* v3 -> v4: Rebase and fix conflicts - no functional changes intended
src/b4/command.py | 2 ++ src/b4/ty.py | 19 ++++++++++--------- 2 files changed, 12 insertions(+), 9 deletions(-)
src/b4/command.py +2 -0
@@ -270,6 +270,8 @@ def setup_parser() -> argparse.ArgumentParser: help='Print out emails instead of sending them') sp_ty.add_argument('--pw-set-state', default=None, help='Set this patchwork state instead of default (use with -a, -t or -d)') + sp_ty.add_argument('--me-too', action='store_true', dest='metoo', default=False, + help='Send a copy of the thanks mail to yourself - ensures a copy lands in your inbox') sp_ty.set_defaults(func=cmd_ty) # b4 diff
src/b4/ty.py +10 -9
@@ -78,14 +78,15 @@ def git_get_commit_message(gitdir: Optional[str], rev: str) -> Tuple[int, Union[ return b4.git_run_command(gitdir, args) -def make_reply(reply_template: str, jsondata: Dict[str, str], gitdir: Optional[str]) -> email.message.EmailMessage: +def make_reply(reply_template: str, jsondata: Dict[str, str], gitdir: Optional[str], cmdargs: argparse.Namespace) -> email.message.EmailMessage: msg = email.message.EmailMessage() msg['From'] = '%s <%s>' % (jsondata['myname'], jsondata['myemail']) excludes = b4.get_excluded_addrs() newto = b4.cleanup_email_addrs([(jsondata['fromname'], jsondata['fromemail'])], excludes, gitdir) # Exclude ourselves and original sender from allto or allcc - excludes.add(jsondata['myemail']) + if not cmdargs.metoo: + excludes.add(jsondata['myemail']) excludes.add(jsondata['fromemail']) allto = b4.cleanup_email_addrs(utils.getaddresses([jsondata['to']]), excludes, gitdir) allcc = b4.cleanup_email_addrs(utils.getaddresses([jsondata['cc']]), excludes, gitdir)
@@ -269,7 +270,7 @@ def set_branch_details(gitdir: Optional[str], branch: str, jsondata: Dict[str, s return jsondata, config -def generate_pr_thanks(gitdir: Optional[str], jsondata: Dict[str, str], branch: str) -> email.message.EmailMessage: +def generate_pr_thanks(gitdir: Optional[str], jsondata: Dict[str, str], branch: str, cmdargs: argparse.Namespace) -> email.message.EmailMessage: config = b4.get_main_config() jsondata, config = set_branch_details(gitdir, branch, jsondata, config) thanks_template = DEFAULT_PR_TEMPLATE
@@ -294,11 +295,11 @@ def generate_pr_thanks(gitdir: Optional[str], jsondata: Dict[str, str], branch: if not cidmask: cidmask = 'merge commit: %s' jsondata['summary'] = cidmask % jsondata['merge_commit_id'] - msg = make_reply(thanks_template, jsondata, gitdir) + msg = make_reply(thanks_template, jsondata, gitdir, cmdargs) return msg -def generate_am_thanks(gitdir: Optional[str], jsondata: Dict[str, str], branch: str, since: str) -> email.message.EmailMessage: +def generate_am_thanks(gitdir: Optional[str], jsondata: Dict[str, str], branch: str, cmdargs: argparse.Namespace) -> email.message.EmailMessage: config = b4.get_main_config() jsondata, config = set_branch_details(gitdir, branch, jsondata, config) thanks_template = DEFAULT_AM_TEMPLATE
@@ -311,7 +312,7 @@ def generate_am_thanks(gitdir: Optional[str], jsondata: Dict[str, str], branch: config['thanks-am-template']) sys.exit(2) if 'commits' not in jsondata: - commits = auto_locate_series(gitdir, jsondata, branch, since) + commits = auto_locate_series(gitdir, jsondata, branch, cmdargs.since) else: commits = jsondata['commits']
@@ -342,7 +343,7 @@ def generate_am_thanks(gitdir: Optional[str], jsondata: Dict[str, str], branch: nomatch, len(commits), jsondata['subject']) logger.critical(' Please review the resulting message') - msg = make_reply(thanks_template, jsondata, gitdir) + msg = make_reply(thanks_template, jsondata, gitdir, cmdargs) return msg
@@ -424,10 +425,10 @@ def send_messages(listing: List[Dict], branch: str, cmdargs: argparse.Namespace) jsondata['signature'] = signature if 'pr_commit_id' in jsondata: # This is a pull request - msg = generate_pr_thanks(gitdir, jsondata, branch) + msg = generate_pr_thanks(gitdir, jsondata, branch, cmdargs) else: # This is a patch series - msg = generate_am_thanks(gitdir, jsondata, branch, cmdargs.since) + msg = generate_am_thanks(gitdir, jsondata, branch, cmdargs) if msg is None: continue
Signature · 1 line
2.50.0.rc2.692.g299adb8693-goog
Konstantin Ryabitsev
AppliedQuoted 9 lines · Lee Jones
The motivation behind this change was that thank-yous weren't showing up in maintainer's inboxes. This is a problem because some of us the presence of these mails to indicate that particular sets or individual patches have been applied or not.
Provide command line option '--me-too' to override the default behaviour. If this is not specified, there are no functional changes.
[...]
Applied, thanks!
[1/1] ty: Allow users to specify whether thank-yous are sent to themselves
commit: fade5953b9dca02aac518d786b09aa0142d64a0a
Best regards,
Signature · 1 line
Konstantin Ryabitsev <[email protected]>