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>
diff --git a/git_footers.py b/git_footers.py
index b882ac3..05d1cbe 100755
--- a/git_footers.py
+++ b/git_footers.py
@@ -66,6 +66,12 @@
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):