diff options
author | Konstantin Ryabitsev <konstantin@linuxfoundation.org> | 2020-02-20 17:42:30 -0500 |
---|---|---|
committer | Konstantin Ryabitsev <konstantin@linuxfoundation.org> | 2020-02-20 17:42:30 -0500 |
commit | e88369f0b62def16752491cc62bc57c4a345afd9 (patch) | |
tree | c38a28a3f27b2663dca1491513e55e441debabd8 | |
parent | 43d52c9d6d8ce4699f4457733f3dd6f29b1515e8 (diff) | |
download | korg-helpers-e88369f0b62def16752491cc62bc57c4a345afd9.tar.gz |
Match binary blob patches sent to linux-firmware
Handle special case when patches don't contain ---/+++ because they are
a "GIT binary patch".
Signed-off-by: Konstantin Ryabitsev <konstantin@linuxfoundation.org>
-rwxr-xr-x | get-lore-mbox.py | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/get-lore-mbox.py b/get-lore-mbox.py index 2c12dbd..851248c 100755 --- a/get-lore-mbox.py +++ b/get-lore-mbox.py @@ -30,7 +30,7 @@ charset.add_charset('utf-8', None) emlpolicy = email.policy.EmailPolicy(utf8=True, cte_type='8bit', max_line_length=None) logger = logging.getLogger('get-lore-mbox') -VERSION = '0.2.6' +VERSION = '0.2.7' # You can use bash-style globbing here WANTHDRS = [ @@ -352,6 +352,9 @@ class LoreMessage: except IndexError: pass + diffre = re.compile(r'^(---.*\n\+\+\+|GIT binary patch)', re.M | re.I) + diffstatre = re.compile(r'^\s*\d+ file.*\d+ insertion.*\d+ deletion', re.M | re.I) + # walk until we find the first text/plain part mcharset = self.msg.get_content_charset() if not mcharset: @@ -373,12 +376,12 @@ class LoreMessage: continue # If we already found a body, but we now find something that contains a diff, # then we prefer this part - if re.search(r'^---.*\n\+\+\+', payload, re.MULTILINE): + if diffre.search(payload): self.body = payload - if re.search(r'^\s*\d+ file.*\d+ insertion.*\d+ deletion', self.body, re.MULTILINE | re.IGNORECASE): + if diffstatre.search(self.body): self.has_diffstat = True - if re.search(r'^---.*\n\+\+\+', self.body, re.MULTILINE): + if diffre.search(self.body): self.has_diff = True # We only pay attention to trailers that are sent in reply |