mirror of
https://chromium.googlesource.com/chromium/tools/depot_tools.git
synced 2026-01-11 10:41:31 +00:00
git_footer: be more resilient to malformed footers
Since split_footers became more resilient to malformed footers and started returning the entire last paragraph, instead of just the last paragraph iff it was entirely well-formed, other functions like remove_footer need to make sure they handle the case where not every line of the footer paragraph can be parsed. R=iannucci@chromium.org Bug: 740601 Change-Id: I75c6c626d96942181f453abeee896ee92d14b20b Reviewed-on: https://chromium-review.googlesource.com/565779 Reviewed-by: Robbie Iannucci <iannucci@chromium.org> Commit-Queue: Aaron Gable <agable@chromium.org>
This commit is contained in:
@@ -146,8 +146,15 @@ def remove_footer(message, key):
|
||||
top_lines, footer_lines, _ = split_footers(message)
|
||||
if not footer_lines:
|
||||
return message
|
||||
new_footer_lines = [
|
||||
l for l in footer_lines if normalize_name(parse_footer(l)[0]) != key]
|
||||
new_footer_lines = []
|
||||
for line in footer_lines:
|
||||
try:
|
||||
f = normalize_name(parse_footer(line)[0])
|
||||
if f != key:
|
||||
new_footer_lines.append(line)
|
||||
except TypeError:
|
||||
# If the footer doesn't parse (i.e. is malformed), just let it carry over.
|
||||
new_footer_lines.append(line)
|
||||
return '\n'.join(top_lines + new_footer_lines)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user