diff mbox series

[b4,v2] sendemail.smtpServerOption can be specified multiple times

Message ID 20240823-fix-multiple-smtpserveroption-v2-1-e9df83f7b3f1@gmail.com (mailing list archive)
State Accepted
Headers show
Series [b4,v2] sendemail.smtpServerOption can be specified multiple times | expand

Commit Message

Celeste Liu Aug. 22, 2024, 6:32 p.m. UTC
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 <j.granados@samsung.com>
Signed-off-by: Celeste Liu <CoelacanthusHex@gmail.com>
---
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(-)


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

Best regards,

Comments

Konstantin Ryabitsev Sept. 6, 2024, 2:47 p.m. UTC | #1
On Fri, 23 Aug 2024 02:32:52 +0800, Celeste Liu wrote:
> 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,
diff mbox series

Patch

diff --git a/src/b4/__init__.py b/src/b4/__init__.py
index 2b1a058..7c5c237 100644
--- a/src/b4/__init__.py
+++ b/src/b4/__init__.py
@@ -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