Skip to contentSkip to conversation

ty: Allow a custom name/from when sending thanks

PATCH Applied Michael Ellerman 2 participants 2 messages Mar 10, 2023

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ty: Allow a custom name/from when sending thanks

Add config options "thanks-from-name" and "thanks-from-email" that allow setting a custom name and/or from address when sending thanks.

---
 b4/ty.py        |  8 +++++---
 docs/config.rst | 14 ++++++++++++++
 2 files changed, 19 insertions(+), 3 deletions(-)
b4/ty.py +5 -3
index 15b02ed..165afd9 100644
@@ -440,13 +440,16 @@ BRANCH_INFO = None
             os.mkdir(cmdargs.outdir)
 
     usercfg = b4.get_user_config()
+    config = b4.get_main_config()
+    user_name = config.get('thanks-from-name', usercfg['name'])
+    user_email = config.get('thanks-from-email', usercfg['email'])
     signature = b4.get_email_signature()
 
     outgoing = 0
     msgids = list()
     for jsondata in listing:
-        jsondata['myname'] = usercfg['name']
-        jsondata['myemail'] = usercfg['email']
+        jsondata['myname'] = user_name
+        jsondata['myemail'] = user_email
         jsondata['signature'] = signature
         if 'pr_commit_id' in jsondata:
             # This is a pull request
@@ -489,7 +492,6 @@ BRANCH_INFO = None
         logger.info('No thanks necessary.')
         return
 
-    config = b4.get_main_config()
     pwstate = cmdargs.pw_set_state
     if not pwstate:
         pwstate = config.get('pw-accept-state')
docs/config.rst +14 -0
index 389badf..c43f32d 100644
@@ -257,6 +257,20 @@ These settings control the behaviour of ``b4 ty`` command.
 
   Default: ``None``
 
+``b4.thanks-from-name`` (v0.13+)
+  An custom from name for sending thanks, eg::
+
+      thanks-from-name = Project Foo Thanks Bot
+
+  Default: ``None`` - falls back to user name.
+
+``b4.thanks-from-email``
+  An custom from email for sending thanks, eg::
+
+      thanks-from-email = [email protected]
+
+  Default: ``None`` - falls back to user email.
+
 ``b4.email-exclude`` (v0.9+)
   A comma-separated list of shell-style globbing patterns with addresses
   that should always be excluded from the recipient list.
Signature · 1 line
2.39.2
#1 lore raw
Quoted 4 lines · Michael Ellerman

Add config options "thanks-from-name" and "thanks-from-email" that allow setting a custom name and/or from address when sending thanks.

Applied, thanks!

[1/1] ty: Allow a custom name/from when sending thanks

      commit: 63fb2ff10b04b383cdc0db3f2a568209e2595222

Best regards,

Signature · 1 line
Konstantin Ryabitsev <[email protected]>