mirror of
https://github.com/brain-hackers/u-boot-brain
synced 2024-06-09 23:36:03 +09:00
patman: Quieten down the alias checking
When a tag is used in a patch subject (e.g. "tag: rest of message") and it cannot be found as an alias, patman currently reports a fatal error, unless -t is provided, in which case it reports a warning. Experience suggest that the fatal error is not very useful. Instead, default to reporting a warning, with -t tell patman to ignore it altogether. Signed-off-by: Simon Glass <sjg@chromium.org>
This commit is contained in:
parent
c7e42cabed
commit
0fb560d9a7
|
@ -186,7 +186,7 @@ class TestFunctional(unittest.TestCase):
|
||||||
- Commit-notes
|
- Commit-notes
|
||||||
"""
|
"""
|
||||||
process_tags = True
|
process_tags = True
|
||||||
ignore_bad_tags = True
|
ignore_bad_tags = False
|
||||||
stefan = b'Stefan Br\xc3\xbcns <stefan.bruens@rwth-aachen.de>'.decode('utf-8')
|
stefan = b'Stefan Br\xc3\xbcns <stefan.bruens@rwth-aachen.de>'.decode('utf-8')
|
||||||
rick = 'Richard III <richard@palace.gov>'
|
rick = 'Richard III <richard@palace.gov>'
|
||||||
mel = b'Lord M\xc3\xablchett <clergy@palace.gov>'.decode('utf-8')
|
mel = b'Lord M\xc3\xablchett <clergy@palace.gov>'.decode('utf-8')
|
||||||
|
|
|
@ -345,7 +345,7 @@ def CreatePatches(branch, start, count, ignore_binary, series, signoff = True):
|
||||||
else:
|
else:
|
||||||
return None, files
|
return None, files
|
||||||
|
|
||||||
def BuildEmailList(in_list, tag=None, alias=None, raise_on_error=True):
|
def BuildEmailList(in_list, tag=None, alias=None, warn_on_error=True):
|
||||||
"""Build a list of email addresses based on an input list.
|
"""Build a list of email addresses based on an input list.
|
||||||
|
|
||||||
Takes a list of email addresses and aliases, and turns this into a list
|
Takes a list of email addresses and aliases, and turns this into a list
|
||||||
|
@ -359,7 +359,7 @@ def BuildEmailList(in_list, tag=None, alias=None, raise_on_error=True):
|
||||||
in_list: List of aliases/email addresses
|
in_list: List of aliases/email addresses
|
||||||
tag: Text to put before each address
|
tag: Text to put before each address
|
||||||
alias: Alias dictionary
|
alias: Alias dictionary
|
||||||
raise_on_error: True to raise an error when an alias fails to match,
|
warn_on_error: True to raise an error when an alias fails to match,
|
||||||
False to just print a message.
|
False to just print a message.
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
|
@ -382,7 +382,7 @@ def BuildEmailList(in_list, tag=None, alias=None, raise_on_error=True):
|
||||||
quote = '"' if tag and tag[0] == '-' else ''
|
quote = '"' if tag and tag[0] == '-' else ''
|
||||||
raw = []
|
raw = []
|
||||||
for item in in_list:
|
for item in in_list:
|
||||||
raw += LookupEmail(item, alias, raise_on_error=raise_on_error)
|
raw += LookupEmail(item, alias, warn_on_error=warn_on_error)
|
||||||
result = []
|
result = []
|
||||||
for item in raw:
|
for item in raw:
|
||||||
if not item in result:
|
if not item in result:
|
||||||
|
@ -416,7 +416,7 @@ def CheckSuppressCCConfig():
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def EmailPatches(series, cover_fname, args, dry_run, raise_on_error, cc_fname,
|
def EmailPatches(series, cover_fname, args, dry_run, warn_on_error, cc_fname,
|
||||||
self_only=False, alias=None, in_reply_to=None, thread=False,
|
self_only=False, alias=None, in_reply_to=None, thread=False,
|
||||||
smtp_server=None):
|
smtp_server=None):
|
||||||
"""Email a patch series.
|
"""Email a patch series.
|
||||||
|
@ -426,8 +426,8 @@ def EmailPatches(series, cover_fname, args, dry_run, raise_on_error, cc_fname,
|
||||||
cover_fname: filename of cover letter
|
cover_fname: filename of cover letter
|
||||||
args: list of filenames of patch files
|
args: list of filenames of patch files
|
||||||
dry_run: Just return the command that would be run
|
dry_run: Just return the command that would be run
|
||||||
raise_on_error: True to raise an error when an alias fails to match,
|
warn_on_error: True to print a warning when an alias fails to match,
|
||||||
False to just print a message.
|
False to ignore it.
|
||||||
cc_fname: Filename of Cc file for per-commit Cc
|
cc_fname: Filename of Cc file for per-commit Cc
|
||||||
self_only: True to just email to yourself as a test
|
self_only: True to just email to yourself as a test
|
||||||
in_reply_to: If set we'll pass this to git as --in-reply-to.
|
in_reply_to: If set we'll pass this to git as --in-reply-to.
|
||||||
|
@ -475,7 +475,7 @@ send --cc-cmd cc-fname" cover p1 p2'
|
||||||
# Restore argv[0] since we clobbered it.
|
# Restore argv[0] since we clobbered it.
|
||||||
>>> sys.argv[0] = _old_argv0
|
>>> sys.argv[0] = _old_argv0
|
||||||
"""
|
"""
|
||||||
to = BuildEmailList(series.get('to'), '--to', alias, raise_on_error)
|
to = BuildEmailList(series.get('to'), '--to', alias, warn_on_error)
|
||||||
if not to:
|
if not to:
|
||||||
git_config_to = command.Output('git', 'config', 'sendemail.to',
|
git_config_to = command.Output('git', 'config', 'sendemail.to',
|
||||||
raise_on_error=False)
|
raise_on_error=False)
|
||||||
|
@ -487,9 +487,9 @@ send --cc-cmd cc-fname" cover p1 p2'
|
||||||
"git config sendemail.to u-boot@lists.denx.de")
|
"git config sendemail.to u-boot@lists.denx.de")
|
||||||
return
|
return
|
||||||
cc = BuildEmailList(list(set(series.get('cc')) - set(series.get('to'))),
|
cc = BuildEmailList(list(set(series.get('cc')) - set(series.get('to'))),
|
||||||
'--cc', alias, raise_on_error)
|
'--cc', alias, warn_on_error)
|
||||||
if self_only:
|
if self_only:
|
||||||
to = BuildEmailList([os.getenv('USER')], '--to', alias, raise_on_error)
|
to = BuildEmailList([os.getenv('USER')], '--to', alias, warn_on_error)
|
||||||
cc = []
|
cc = []
|
||||||
cmd = ['git', 'send-email', '--annotate']
|
cmd = ['git', 'send-email', '--annotate']
|
||||||
if smtp_server:
|
if smtp_server:
|
||||||
|
@ -511,7 +511,7 @@ send --cc-cmd cc-fname" cover p1 p2'
|
||||||
return cmdstr
|
return cmdstr
|
||||||
|
|
||||||
|
|
||||||
def LookupEmail(lookup_name, alias=None, raise_on_error=True, level=0):
|
def LookupEmail(lookup_name, alias=None, warn_on_error=True, level=0):
|
||||||
"""If an email address is an alias, look it up and return the full name
|
"""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?
|
TODO: Why not just use git's own alias feature?
|
||||||
|
@ -519,8 +519,8 @@ def LookupEmail(lookup_name, alias=None, raise_on_error=True, level=0):
|
||||||
Args:
|
Args:
|
||||||
lookup_name: Alias or email address to look up
|
lookup_name: Alias or email address to look up
|
||||||
alias: Dictionary containing aliases (None to use settings default)
|
alias: Dictionary containing aliases (None to use settings default)
|
||||||
raise_on_error: True to raise an error when an alias fails to match,
|
warn_on_error: True to print a warning when an alias fails to match,
|
||||||
False to just print a message.
|
False to ignore it.
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
tuple:
|
tuple:
|
||||||
|
@ -547,18 +547,16 @@ def LookupEmail(lookup_name, alias=None, raise_on_error=True, level=0):
|
||||||
>>> LookupEmail('all', alias)
|
>>> LookupEmail('all', alias)
|
||||||
['f.bloggs@napier.co.nz', 'j.bloggs@napier.co.nz', 'm.poppins@cloud.net']
|
['f.bloggs@napier.co.nz', 'j.bloggs@napier.co.nz', 'm.poppins@cloud.net']
|
||||||
>>> LookupEmail('odd', alias)
|
>>> LookupEmail('odd', alias)
|
||||||
Traceback (most recent call last):
|
Alias 'odd' not found
|
||||||
...
|
[]
|
||||||
ValueError: Alias 'odd' not found
|
|
||||||
>>> LookupEmail('loop', alias)
|
>>> LookupEmail('loop', alias)
|
||||||
Traceback (most recent call last):
|
Traceback (most recent call last):
|
||||||
...
|
...
|
||||||
OSError: Recursive email alias at 'other'
|
OSError: Recursive email alias at 'other'
|
||||||
>>> LookupEmail('odd', alias, raise_on_error=False)
|
>>> LookupEmail('odd', alias, warn_on_error=False)
|
||||||
Alias 'odd' not found
|
|
||||||
[]
|
[]
|
||||||
>>> # In this case the loop part will effectively be ignored.
|
>>> # In this case the loop part will effectively be ignored.
|
||||||
>>> LookupEmail('loop', alias, raise_on_error=False)
|
>>> LookupEmail('loop', alias, warn_on_error=False)
|
||||||
Recursive email alias at 'other'
|
Recursive email alias at 'other'
|
||||||
Recursive email alias at 'john'
|
Recursive email alias at 'john'
|
||||||
Recursive email alias at 'mary'
|
Recursive email alias at 'mary'
|
||||||
|
@ -576,7 +574,7 @@ def LookupEmail(lookup_name, alias=None, raise_on_error=True, level=0):
|
||||||
out_list = []
|
out_list = []
|
||||||
if level > 10:
|
if level > 10:
|
||||||
msg = "Recursive email alias at '%s'" % lookup_name
|
msg = "Recursive email alias at '%s'" % lookup_name
|
||||||
if raise_on_error:
|
if warn_on_error:
|
||||||
raise OSError(msg)
|
raise OSError(msg)
|
||||||
else:
|
else:
|
||||||
print(col.Color(col.RED, msg))
|
print(col.Color(col.RED, msg))
|
||||||
|
@ -585,18 +583,15 @@ def LookupEmail(lookup_name, alias=None, raise_on_error=True, level=0):
|
||||||
if lookup_name:
|
if lookup_name:
|
||||||
if not lookup_name in alias:
|
if not lookup_name in alias:
|
||||||
msg = "Alias '%s' not found" % lookup_name
|
msg = "Alias '%s' not found" % lookup_name
|
||||||
if raise_on_error:
|
if warn_on_error:
|
||||||
raise ValueError(msg)
|
|
||||||
else:
|
|
||||||
print(col.Color(col.RED, msg))
|
print(col.Color(col.RED, msg))
|
||||||
return out_list
|
return out_list
|
||||||
for item in alias[lookup_name]:
|
for item in alias[lookup_name]:
|
||||||
todo = LookupEmail(item, alias, raise_on_error, level + 1)
|
todo = LookupEmail(item, alias, warn_on_error, level + 1)
|
||||||
for new_item in todo:
|
for new_item in todo:
|
||||||
if not new_item in out_list:
|
if not new_item in out_list:
|
||||||
out_list.append(new_item)
|
out_list.append(new_item)
|
||||||
|
|
||||||
#print("No match for alias '%s'" % lookup_name)
|
|
||||||
return out_list
|
return out_list
|
||||||
|
|
||||||
def GetTopLevel():
|
def GetTopLevel():
|
||||||
|
|
|
@ -68,7 +68,8 @@ send.add_argument('-n', '--dry-run', action='store_true', dest='dry_run',
|
||||||
send.add_argument('-r', '--in-reply-to', type=str, action='store',
|
send.add_argument('-r', '--in-reply-to', type=str, action='store',
|
||||||
help="Message ID that this series is in reply to")
|
help="Message ID that this series is in reply to")
|
||||||
send.add_argument('-t', '--ignore-bad-tags', action='store_true',
|
send.add_argument('-t', '--ignore-bad-tags', action='store_true',
|
||||||
default=False, help='Ignore bad tags / aliases')
|
default=False,
|
||||||
|
help='Ignore bad tags / aliases (default=warn)')
|
||||||
send.add_argument('-T', '--thread', action='store_true', dest='thread',
|
send.add_argument('-T', '--thread', action='store_true', dest='thread',
|
||||||
default=False, help='Create patches as a single thread')
|
default=False, help='Create patches as a single thread')
|
||||||
send.add_argument('--cc-cmd', dest='cc_cmd', type=str, action='store',
|
send.add_argument('--cc-cmd', dest='cc_cmd', type=str, action='store',
|
||||||
|
@ -176,6 +177,9 @@ elif args.cmd == 'send':
|
||||||
command.Run(pager, fname)
|
command.Run(pager, fname)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
|
# If we are not processing tags, no need to warning about bad ones
|
||||||
|
if not args.process_tags:
|
||||||
|
args.ignore_bad_tags = True
|
||||||
control.send(args)
|
control.send(args)
|
||||||
|
|
||||||
# Check status of patches in patchwork
|
# Check status of patches in patchwork
|
||||||
|
|
|
@ -234,7 +234,7 @@ class Series(dict):
|
||||||
str = 'Change log exists, but no version is set'
|
str = 'Change log exists, but no version is set'
|
||||||
print(col.Color(col.RED, str))
|
print(col.Color(col.RED, str))
|
||||||
|
|
||||||
def MakeCcFile(self, process_tags, cover_fname, raise_on_error,
|
def MakeCcFile(self, process_tags, cover_fname, warn_on_error,
|
||||||
add_maintainers, limit):
|
add_maintainers, limit):
|
||||||
"""Make a cc file for us to use for per-commit Cc automation
|
"""Make a cc file for us to use for per-commit Cc automation
|
||||||
|
|
||||||
|
@ -243,8 +243,8 @@ class Series(dict):
|
||||||
Args:
|
Args:
|
||||||
process_tags: Process tags as if they were aliases
|
process_tags: Process tags as if they were aliases
|
||||||
cover_fname: If non-None the name of the cover letter.
|
cover_fname: If non-None the name of the cover letter.
|
||||||
raise_on_error: True to raise an error when an alias fails to match,
|
warn_on_error: True to print a warning when an alias fails to match,
|
||||||
False to just print a message.
|
False to ignore it.
|
||||||
add_maintainers: Either:
|
add_maintainers: Either:
|
||||||
True/False to call the get_maintainers to CC maintainers
|
True/False to call the get_maintainers to CC maintainers
|
||||||
List of maintainers to include (for testing)
|
List of maintainers to include (for testing)
|
||||||
|
@ -261,9 +261,9 @@ class Series(dict):
|
||||||
cc = []
|
cc = []
|
||||||
if process_tags:
|
if process_tags:
|
||||||
cc += gitutil.BuildEmailList(commit.tags,
|
cc += gitutil.BuildEmailList(commit.tags,
|
||||||
raise_on_error=raise_on_error)
|
warn_on_error=warn_on_error)
|
||||||
cc += gitutil.BuildEmailList(commit.cc_list,
|
cc += gitutil.BuildEmailList(commit.cc_list,
|
||||||
raise_on_error=raise_on_error)
|
warn_on_error=warn_on_error)
|
||||||
if type(add_maintainers) == type(cc):
|
if type(add_maintainers) == type(cc):
|
||||||
cc += add_maintainers
|
cc += add_maintainers
|
||||||
elif add_maintainers:
|
elif add_maintainers:
|
||||||
|
|
Loading…
Reference in New Issue
Block a user