* [PATCH v2 1/1] ty: Allow users to specify whether thank-yous are sent to themselves
@ 2025-05-01 9:15 Lee Jones
2025-05-01 16:17 ` Konstantin Ryabitsev
0 siblings, 1 reply; 3+ messages in thread
From: Lee Jones @ 2025-05-01 9:15 UTC (permalink / raw)
To: konstantin; +Cc: tools, Lee Jones
The motivation behind this change was that thanks-yous weren't showing
up in my inbox. This is a problem because I use the presence of these
mails to indicate that particular sets or individual patches have been
applied or not.
Provide command line option '--send-to-self' to override the default
behaviour. If this is not specified, there are no functional changes.
Closes: https://bugzilla.kernel.org/show_bug.cgi?id=217672
Signed-off-by: Lee Jones <lee@kernel.org>
---
v1 => v2:
- Commit message update
src/b4/command.py | 2 ++
src/b4/ty.py | 19 ++++++++++---------
2 files changed, 12 insertions(+), 9 deletions(-)
diff --git a/src/b4/command.py b/src/b4/command.py
index 617a2d7ded8f..777987f06aa7 100644
--- a/src/b4/command.py
+++ b/src/b4/command.py
@@ -266,6 +266,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('--send-to-self', action='store_true', dest='sendtoself', 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
diff --git a/src/b4/ty.py b/src/b4/ty.py
index 021588ff9e55..f6a4f63bb3da 100644
--- a/src/b4/ty.py
+++ b/src/b4/ty.py
@@ -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, gitdir: Optional[str]) -> email.message.EmailMessage:
+def make_reply(reply_template: str, jsondata: dict, 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.sendtoself:
+ 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)
@@ -270,7 +271,7 @@ def set_branch_details(gitdir: Optional[str], branch: str, jsondata: dict, confi
return jsondata, config
-def generate_pr_thanks(gitdir: Optional[str], jsondata: dict, branch: str) -> email.message.EmailMessage:
+def generate_pr_thanks(gitdir: Optional[str], jsondata: dict, 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
@@ -295,11 +296,11 @@ def generate_pr_thanks(gitdir: Optional[str], jsondata: dict, branch: str) -> em
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, branch: str, since: str) -> email.message.EmailMessage:
+def generate_am_thanks(gitdir: Optional[str], jsondata: dict, 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
@@ -312,7 +313,7 @@ def generate_am_thanks(gitdir: Optional[str], jsondata: dict, branch: str, since
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']
@@ -343,7 +344,7 @@ def generate_am_thanks(gitdir: Optional[str], jsondata: dict, branch: str, since
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
@@ -425,10 +426,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
--
2.48.1.502.g6dc24dfdaf-goog
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH v2 1/1] ty: Allow users to specify whether thank-yous are sent to themselves
2025-05-01 9:15 [PATCH v2 1/1] ty: Allow users to specify whether thank-yous are sent to themselves Lee Jones
@ 2025-05-01 16:17 ` Konstantin Ryabitsev
2025-05-02 8:18 ` Lee Jones
0 siblings, 1 reply; 3+ messages in thread
From: Konstantin Ryabitsev @ 2025-05-01 16:17 UTC (permalink / raw)
To: Lee Jones; +Cc: tools
On Thu, May 01, 2025 at 10:15:02AM +0100, Lee Jones wrote:
> The motivation behind this change was that thanks-yous weren't showing
> up in my inbox. This is a problem because I use the presence of these
> mails to indicate that particular sets or individual patches have been
> applied or not.
>
> Provide command line option '--send-to-self' to override the default
> behaviour. If this is not specified, there are no functional changes.
Can we call it --me-too, to match the --not-me-too option for b4 prep?
-K
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH v2 1/1] ty: Allow users to specify whether thank-yous are sent to themselves
2025-05-01 16:17 ` Konstantin Ryabitsev
@ 2025-05-02 8:18 ` Lee Jones
0 siblings, 0 replies; 3+ messages in thread
From: Lee Jones @ 2025-05-02 8:18 UTC (permalink / raw)
To: Konstantin Ryabitsev; +Cc: tools
On Thu, 01 May 2025, Konstantin Ryabitsev wrote:
> On Thu, May 01, 2025 at 10:15:02AM +0100, Lee Jones wrote:
> > The motivation behind this change was that thanks-yous weren't showing
> > up in my inbox. This is a problem because I use the presence of these
> > mails to indicate that particular sets or individual patches have been
> > applied or not.
> >
> > Provide command line option '--send-to-self' to override the default
> > behaviour. If this is not specified, there are no functional changes.
>
> Can we call it --me-too, to match the --not-me-too option for b4 prep?
Thanks for your review.
Yes, of course. I'll respin next week.
--
Lee Jones [李琼斯]
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2025-05-02 8:18 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-05-01 9:15 [PATCH v2 1/1] ty: Allow users to specify whether thank-yous are sent to themselves Lee Jones
2025-05-01 16:17 ` Konstantin Ryabitsev
2025-05-02 8:18 ` Lee Jones
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).