Use rstrip when getting footer tags

A quick bugfix was made in cc29098042 that removed trailing empty lines
when getting tags out of the git log.  This preserved the behavior that
tags with trailing whitespace would retain said whitespace.

This change instead simplifies the logic that removes trailing
whitespace with the side effect that whitespace at the end of the last
tag is also stripped.  The unittests are adjusted accordingly

Bug: 1130601
Change-Id: I26d39736179b36ac2573de1ca003a5bc09f30a28
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/2423050
Auto-Submit: Shahbaz Youssefi <syoussefi@chromium.org>
Commit-Queue: Dirk Pranke <dpranke@google.com>
Reviewed-by: Dirk Pranke <dpranke@google.com>
diff --git a/git_footers.py b/git_footers.py
index 05d1cbe..a25e562 100755
--- a/git_footers.py
+++ b/git_footers.py
@@ -65,13 +65,7 @@
       There could be fewer parsed_footers than footer lines if some lines in
       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()
-
+  message_lines = list(message.rstrip().splitlines())
   footer_lines = []
   maybe_footer_lines = []
   for line in reversed(message_lines):
diff --git a/tests/git_footers_test.py b/tests/git_footers_test.py
index e04354e..4720b9d 100755
--- a/tests/git_footers_test.py
+++ b/tests/git_footers_test.py
@@ -46,9 +46,15 @@
         git_footers.split_footers('H\n\nBug:\nAlso: footer'),
         (['H', ''], ['Bug:', 'Also: footer'],
          [('Bug', ''), ('Also', 'footer')]))
+    self.assertEqual(git_footers.split_footers('H\n\nBug:      '),
+                     (['H', ''], ['Bug:'], [('Bug', '')]))
+    self.assertEqual(git_footers.split_footers('H\n\nBug: 1234     '),
+                     (['H', ''], ['Bug: 1234'], [('Bug', '1234')]))
     self.assertEqual(
-        git_footers.split_footers('H\n\nBug:      '),
-        (['H', ''], ['Bug:      '], [('Bug', '')]))
+        git_footers.split_footers('H\n\nBug: 1234\nChange-Id: Ib4321  '),
+        (['H', ''], ['Bug: 1234', 'Change-Id: Ib4321'], [('Bug', '1234'),
+                                                         ('Change-Id', 'Ib4321')
+                                                         ]))
 
     self.assertEqual(
         git_footers.parse_footers(self._message), {})