mirror of
https://source.denx.de/u-boot/u-boot.git
synced 2026-05-06 05:06:13 +02:00
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>
This commit is contained in:
parent
7dc55435b2
commit
e10201aa8c
@ -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)
|
||||
|
||||
@ -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"))
|
||||
|
||||
@ -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]
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user