From 6f4a1e8449a4a4bcb135bcad784e91e2a31ff093 Mon Sep 17 00:00:00 2001 From: Konstantin Ryabitsev Date: Wed, 9 Dec 2020 17:48:51 -0500 Subject: Only check allow-list of trailers in follow-ups We only need to check against the list of known non-person trailers if we're looking at follow-up messages. Any trailers we see in the actual commit messages can be taken at their face value. Signed-off-by: Konstantin Ryabitsev --- b4/__init__.py | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/b4/__init__.py b/b4/__init__.py index 3ab0da6..4270b40 100644 --- a/b4/__init__.py +++ b/b4/__init__.py @@ -887,10 +887,10 @@ class LoreMessage: # We only pay attention to trailers that are sent in reply if self.reply: - trailers, others = LoreMessage.find_trailers(self.body) + trailers, others = LoreMessage.find_trailers(self.body, followup=True) for trailer in trailers: # These are commonly part of patch/commit metadata - badtrailers = ('from', 'author', 'cc') + badtrailers = ('from', 'author', 'cc', 'to') if trailer[0].lower() not in badtrailers: self.trailers.append(trailer) @@ -1194,8 +1194,8 @@ class LoreMessage: self.attestation = LoreAttestation(i, m, p) @staticmethod - def find_trailers(body): - headers = ('subject', 'date', 'from', 'to') + def find_trailers(body, followup=False): + headers = ('subject', 'date', 'from') nonperson = ('fixes', 'subject', 'date', 'link', 'buglink') # Fix some more common copypasta trailer wrapping # Fixes: abcd0123 (foo bar @@ -1222,10 +1222,11 @@ class LoreMessage: if len(others) and tname in headers: logger.debug('Ignoring %s (header after other content)', line) continue - mperson = re.search(r'\S+@\S+\.\S+', groups[1]) - if not mperson and tname not in nonperson: - logger.debug('Ignoring %s (not a recognized non-person trailer)', line) - continue + if followup: + mperson = re.search(r'\S+@\S+\.\S+', groups[1]) + if not mperson and tname not in nonperson: + logger.debug('Ignoring %s (not a recognized non-person trailer)', line) + continue was_trailer = True groups.append(None) trailers.append(groups) -- cgit v1.2.3