Rather than accessing the settings module in this function, require the alias dict to be passed in.
Signed-off-by: Simon Glass <s...@chromium.org> --- tools/patman/control.py | 2 +- tools/patman/func_test.py | 5 +++-- tools/u_boot_pylib/gitutil.py | 19 ++++++++----------- 3 files changed, 12 insertions(+), 14 deletions(-) diff --git a/tools/patman/control.py b/tools/patman/control.py index c1b6e41e2d2..f578336c7cc 100644 --- a/tools/patman/control.py +++ b/tools/patman/control.py @@ -153,7 +153,7 @@ def email_patches(col, series, cover_fname, patch_files, process_tags, its_a_go, if its_a_go: cmd = gitutil.email_patches( series, cover_fname, patch_files, dry_run, not ignore_bad_tags, - cc_file, in_reply_to=in_reply_to, thread=thread, + cc_file, settings.alias, in_reply_to=in_reply_to, thread=thread, smtp_server=smtp_server) else: print(col.build(col.RED, "Not sending emails due to errors/warnings")) diff --git a/tools/patman/func_test.py b/tools/patman/func_test.py index 720746e21f5..b8fb49c34ba 100644 --- a/tools/patman/func_test.py +++ b/tools/patman/func_test.py @@ -206,13 +206,14 @@ class TestFunctional(unittest.TestCase): dry_run = True in_reply_to = mel count = 2 - settings.alias = { + alias = { 'fdt': ['simon'], 'u-boot': ['u-boot@lists.denx.de'], 'simon': [self.leb], 'fred': [self.fred], 'joe': [self.joe], } + settings.alias = alias text = self._get_text('test01.txt') series = patchstream.get_metadata_for_test(text) @@ -231,7 +232,7 @@ class TestFunctional(unittest.TestCase): None, get_maintainer_script) cmd = gitutil.email_patches( series, cover_fname, args, dry_run, not ignore_bad_tags, - cc_file, in_reply_to=in_reply_to, thread=None) + cc_file, alias, in_reply_to=in_reply_to, thread=None) series.ShowActions(args, cmd, process_tags) cc_lines = open(cc_file, encoding='utf-8').read().splitlines() os.remove(cc_file) diff --git a/tools/u_boot_pylib/gitutil.py b/tools/u_boot_pylib/gitutil.py index 7c9d0deecbb..7d3a0b68c53 100644 --- a/tools/u_boot_pylib/gitutil.py +++ b/tools/u_boot_pylib/gitutil.py @@ -5,7 +5,6 @@ import os import sys -from patman import settings from u_boot_pylib import command from u_boot_pylib import terminal @@ -437,7 +436,7 @@ def check_suppress_cc_config(): def email_patches(series, cover_fname, args, dry_run, warn_on_error, cc_fname, - self_only=False, alias=None, in_reply_to=None, thread=False, + alias, self_only=False, in_reply_to=None, thread=False, smtp_server=None): """Email a patch series. @@ -449,10 +448,10 @@ def email_patches(series, cover_fname, args, dry_run, warn_on_error, cc_fname, warn_on_error (bool): True to print a warning when an alias fails to match, False to ignore it. cc_fname (str): Filename of Cc file for per-commit Cc - self_only (bool): True to just email to yourself as a test - alias (dict or None): Alias dictionary: (None to use settings default) + alias (dict): Alias dictionary: key: alias value: list of aliases or email addresses + self_only (bool): True to just email to yourself as a test in_reply_to (str or None): If set we'll pass this to git as --in-reply-to - should be a message ID that this is in reply to. thread (bool): True to add --thread to git send-email (make @@ -498,7 +497,7 @@ send --cc-cmd cc-fname" cover p1 p2' # Restore argv[0] since we clobbered it. >>> sys.argv[0] = _old_argv0 """ - to = build_email_list(series.get('to'), settings.alias, '--to', warn_on_error) + to = build_email_list(series.get('to'), alias, '--to', warn_on_error) if not to: git_config_to = command.output('git', 'config', 'sendemail.to', raise_on_error=False) @@ -510,9 +509,9 @@ send --cc-cmd cc-fname" cover p1 p2' "git config sendemail.to u-boot@lists.denx.de") return None cc = build_email_list(list(set(series.get('cc')) - set(series.get('to'))), - settings.alias, '--cc', warn_on_error) + alias, '--cc', warn_on_error) if self_only: - to = build_email_list([os.getenv('USER')], '--to', settings.alias, + to = build_email_list([os.getenv('USER')], '--to', alias, warn_on_error) cc = [] cmd = ['git', 'send-email', '--annotate'] @@ -535,14 +534,14 @@ send --cc-cmd cc-fname" cover p1 p2' return cmdstr -def lookup_email(lookup_name, alias=None, warn_on_error=True, level=0): +def lookup_email(lookup_name, alias, warn_on_error=True, level=0): """If an email address is an alias, look it up and return the full name TODO: Why not just use git's own alias feature? Args: lookup_name (str): Alias or email address to look up - alias (dict or None): Alias dictionary: (None to use settings default) + alias (dict): Alias dictionary key: alias value: list of aliases or email addresses warn_on_error (bool): True to print a warning when an alias fails to @@ -589,8 +588,6 @@ def lookup_email(lookup_name, alias=None, warn_on_error=True, level=0): Recursive email alias at 'mary' ['j.blo...@napier.co.nz', 'm.popp...@cloud.net'] """ - if not alias: - alias = settings.alias lookup_name = lookup_name.strip() if '@' in lookup_name: # Perhaps a real email address return [lookup_name] -- 2.43.0