Skip to contentSkip to conversation

sendemail.smtpServerOption can be specified multiple times

PATCH Applied Celeste Liu 2 participants 2 messages Aug 22, 2024 – Sep 6, 2024

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 sendemail.smtpServerOption can be specified multiple times

In git-send-email(1):

The --smtp-server-option option must be repeated for each option you want to pass to the server. Likewise, different lines in the configuration files must be used for each option.

So this config option must be specified in multivars parameter of get_config_from_git() and be treated as a list.

The default value in get() will be unreachable, remove it.

Fixes 37811c93f5 ("Forward the smtpserveroption to the local command")
Cc Joel Granados <[email protected]>

---
Changes in v2:
- Remove unreachable default value.
- Link to v1: https://patch.msgid.link/20240823-fix-multiple-smtpserveroption-v1-1-0c4879fcb133@gmail.com

---
 src/b4/__init__.py | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
src/b4/__init__.py +4 -4
index 2b1a058..7c5c237 100644
@@ -3728,10 +3728,10 @@ def _setup_sendemail_config(cmdargs: argparse.Namespace) -> None:
     # Get the default settings first
     config = get_main_config()
     identity = config.get('sendemail-identity')
-    _basecfg = get_config_from_git(r'sendemail\.[^.]+$')
+    _basecfg = get_config_from_git(r'sendemail\.[^.]+$', multivals=['smtpserveroption'])
     if identity:
         # Use this identity to override what we got from the default one
-        sconfig = get_config_from_git(rf'sendemail\.{identity}\..*', defaults=_basecfg)
+        sconfig = get_config_from_git(rf'sendemail\.{identity}\..*', multivals=['smtpserveroption'], defaults=_basecfg)
         sectname = f'sendemail.{identity}'
         if not len(sconfig):
             raise smtplib.SMTPException('Unable to find %s settings in any applicable git config' % sectname)
@@ -3783,9 +3783,9 @@ def get_smtp(dryrun: bool = False) -> Tuple[Union[smtplib.SMTP, smtplib.SMTP_SSL
                 envpair = email.utils.parseaddr(env_sender)
             if envpair[1]:
                 smtp += ['-f', envpair[1]]
-        server_option = sconfig.get('smtpserveroption', '')
+        server_option = sconfig.get('smtpserveroption')
         if server_option:
-            smtp += [server_option]
+            smtp += server_option
         logger.debug('sendmail command: %s', ' '.join(smtp))
         return smtp, fromaddr
 

---
base-commit: 37811c93f50e70f325e45107a9a20ffc69f2f6dc
change-id: 20240823-fix-multiple-smtpserveroption-83731eb8b4e7

Best regards,

Signature · 1 line
Celeste Liu <[email protected]>
#1 lore raw
Quoted 10 lines · Celeste Liu

In git-send-email(1):

The --smtp-server-option option must be repeated for each option you want to pass to the server. Likewise, different lines in the configuration files must be used for each option.

So this config option must be specified in multivars parameter of get_config_from_git() and be treated as a list.

[...]

Applied, thanks!

[1/1] sendemail.smtpServerOption can be specified multiple times

      commit: 40f6efe297f364e3bec073971e2f29318bb15431

Best regards,

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