summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2025-04-07 22:51:45 +1200
committerSimon Glass <sjg@chromium.org>2025-05-27 10:07:41 +0100
commite10201aa8ccb1fb681cafab4225399f4fdb8497d (patch)
tree1bb96dd2d6c13d472813be4d840ba5ef0a7e0f57
parent7dc55435b2e869e26ab28926b92a7dc6620e2108 (diff)
patman: Pass the alias dict into gitutil.email_patches()
Rather than accessing the settings module in this function, require the alias dict to be passed in. Signed-off-by: Simon Glass <sjg@chromium.org>
-rw-r--r--tools/patman/func_test.py5
-rw-r--r--tools/patman/send.py3
-rw-r--r--tools/u_boot_pylib/gitutil.py19
3 files changed, 13 insertions, 14 deletions
diff --git a/tools/patman/func_test.py b/tools/patman/func_test.py
index eee20b9b155..b96bf7bd917 100644
--- a/tools/patman/func_test.py
+++ b/tools/patman/func_test.py
@@ -230,13 +230,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)
@@ -255,7 +256,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/patman/send.py b/tools/patman/send.py
index 66f3c4eb952..9481a95f2f9 100644
--- a/tools/patman/send.py
+++ b/tools/patman/send.py
@@ -10,6 +10,7 @@ import sys
from patman import checkpatch
from patman import patchstream
+from patman import settings
from u_boot_pylib import gitutil
from u_boot_pylib import terminal
@@ -93,7 +94,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/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.bloggs@napier.co.nz', 'm.poppins@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]