From bf8574399c9f21ac5279230b1875fd843768f7cf Mon Sep 17 00:00:00 2001 From: Konstantin Ryabitsev Date: Mon, 29 Aug 2022 17:04:11 -0400 Subject: Improve sendemail identity handling The sendemail sections are supposed to be fall-throughs where a named section overrides the values provided by the global section. This implements the required logic to be compliant with git. Suggested-by: Rob Herring Link: https://msgid.link/20220825182506.1449442-1-robh@kernel.org Signed-off-by: Konstantin Ryabitsev --- b4/__init__.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/b4/__init__.py b/b4/__init__.py index 8203a90..fcb31ed 100644 --- a/b4/__init__.py +++ b/b4/__init__.py @@ -2755,11 +2755,14 @@ def read_template(tptfile): def get_smtp(identity: Optional[str] = None, dryrun: bool = False) -> Tuple[Union[smtplib.SMTP, smtplib.SMTP_SSL, None], str]: + # Get the default settings first + _basecfg = get_config_from_git(r'sendemail\.[^.]+$') if identity: - sconfig = get_config_from_git(rf'sendemail\.{identity}\..*') + # Use this identity to override what we got from the default one + sconfig = get_config_from_git(rf'sendemail\.{identity}\..*', defaults=_basecfg) sectname = f'sendemail.{identity}' else: - sconfig = get_config_from_git(rf'sendemail\..*') + sconfig = _basecfg sectname = 'sendemail' if not len(sconfig): raise smtplib.SMTPException('Unable to find %s settings in any applicable git config' % sectname) -- cgit v1.2.3