Strip trailing empty lines when getting footers

Take the following git change description (Note: added ~ to avoid
having these lines be parsed as tags):

```
~Test
~
~Bug: something
~Change-Id: Something
```

Sometimes(?) `git log --pretty=format:%B%n <hash>..` returns:

```
~Test
~
~Bug: something
~Change-Id: Something

```

The trailing empty line trips split_footers() up, making it return
an empty footer.

This change removes trailing empty lines before processing them.

Bug: 1130601
Change-Id: Ib8d6c37ad6817a47a744245d1a2455ac9af6c469
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/2422378
Commit-Queue: Dirk Pranke <dpranke@google.com>
Reviewed-by: Dirk Pranke <dpranke@google.com>
Auto-Submit: Shahbaz Youssefi <syoussefi@chromium.org>
changes/78/2422378/8
Shahbaz Youssefi 5 years ago committed by LUCI CQ
parent e0244d9798
commit cc29098042

@ -66,6 +66,12 @@ def split_footers(message):
last paragraph are malformed.
"""
message_lines = list(message.splitlines())
# First, remove trailing empty lines from the change to get to the footer
while len(message_lines) > 0 and (message_lines[-1] == ''
or message_lines[-1].isspace()):
message_lines.pop()
footer_lines = []
maybe_footer_lines = []
for line in reversed(message_lines):

Loading…
Cancel
Save