Commit cc290980 authored by Shahbaz Youssefi's avatar Shahbaz Youssefi Committed by LUCI CQ

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: 's avatarDirk Pranke <dpranke@google.com>
Auto-Submit: Shahbaz Youssefi <syoussefi@chromium.org>
parent e0244d97
......@@ -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):
......
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