Commit 43ec62ec authored by Andrii Shyshkalov's avatar Andrii Shyshkalov Committed by Commit Bot

Revert "Relax git_footers parsing to match that of Gerrit (JGit)."

This reverts commit 28a5d5de.

Reason for revert: breaks assumption in function for adding footers

Original change's description:
> Relax git_footers parsing to match that of Gerrit (JGit).
> 
> R=​agable@chromium.org
> 
> Bug: 717504
> Change-Id: Ieb6415d55e85b91f11f9052b0fd08cf982b64d51
> Reviewed-on: https://chromium-review.googlesource.com/501849
> Commit-Queue: Andrii Shyshkalov <tandrii@chromium.org>
> Reviewed-by: Aaron Gable <agable@chromium.org>
> 

TBR=agable@chromium.org,machenbach@chromium.org,tandrii@chromium.org
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true
Bug: 717504

Change-Id: I9b4d619b2972be8434aff9464f1959fbcb3abd32
Reviewed-on: https://chromium-review.googlesource.com/503030Reviewed-by: 's avatarAndrii Shyshkalov <tandrii@chromium.org>
Commit-Queue: Andrii Shyshkalov <tandrii@chromium.org>
parent beec0066
...@@ -48,8 +48,6 @@ def split_footers(message): ...@@ -48,8 +48,6 @@ def split_footers(message):
Guarantees that: Guarantees that:
(non_footer_lines + footer_lines) == message.splitlines(). (non_footer_lines + footer_lines) == message.splitlines().
parsed_footers is parse_footer applied on each line of footer_lines. parsed_footers is parse_footer applied on each line of footer_lines.
There could be fewer parsed_footers than footer lines if some lines in
last paragraph are malformed.
""" """
message_lines = list(message.splitlines()) message_lines = list(message.splitlines())
footer_lines = [] footer_lines = []
...@@ -63,8 +61,8 @@ def split_footers(message): ...@@ -63,8 +61,8 @@ def split_footers(message):
footer_lines = [] footer_lines = []
footer_lines.reverse() footer_lines.reverse()
footers = filter(None, map(parse_footer, footer_lines)) footers = map(parse_footer, footer_lines)
if not footers: if not footer_lines or not all(footers):
return message_lines, [], [] return message_lines, [], []
return message_lines[:-len(footer_lines)], footer_lines, footers return message_lines[:-len(footer_lines)], footer_lines, footers
......
...@@ -411,9 +411,9 @@ def get_commit_message_footer_map(message): ...@@ -411,9 +411,9 @@ def get_commit_message_footer_map(message):
for line in lines: for line in lines:
m = COMMIT_FOOTER_ENTRY_RE.match(line) m = COMMIT_FOOTER_ENTRY_RE.match(line)
if not m: if not m:
# If any single line isn't valid, continue anyway for compatibility with # If any single line isn't valid, the entire footer is invalid.
# Gerrit (which itself uses JGit for this). footers.clear()
continue return footers
footers[m.group(1)] = m.group(2).strip() footers[m.group(1)] = m.group(2).strip()
return footers return footers
......
...@@ -59,33 +59,6 @@ My commit message is my best friend. It is my life. I must master it. ...@@ -59,33 +59,6 @@ My commit message is my best friend. It is my life. I must master it.
{ 'Bug': [''], { 'Bug': [''],
'Cr-Commit-Position': [ self._position ] }) 'Cr-Commit-Position': [ self._position ] })
def testSkippingBadFooterLines(self):
message = ('Title.\n'
'\n'
'Last: paragraph starts\n'
'It-may: contain\n'
'bad lines, which should be skipped\n'
'For: example\n'
'(cherry picked from)\n'
'And-only-valid: footers taken')
self.assertEqual(git_footers.split_footers(message),
(['Title.',
''],
['Last: paragraph starts',
'It-may: contain',
'bad lines, which should be skipped',
'For: example',
'(cherry picked from)',
'And-only-valid: footers taken'],
[('Last', 'paragraph starts'),
('It-may', 'contain'),
('For', 'example'),
('And-only-valid', 'footers taken')]))
self.assertEqual(git_footers.parse_footers(message),
{'Last': ['paragraph starts'],
'It-May': ['contain'],
'For': ['example'],
'And-Only-Valid': ['footers taken']})
def testGetFooterChangeId(self): def testGetFooterChangeId(self):
msg = '\n'.join(['whatever', msg = '\n'.join(['whatever',
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment