From 519f2506456ffcf79782f7be21a8463d1776b16c Mon Sep 17 00:00:00 2001 From: Pierre-Marie de Rodat Date: Tue, 26 May 2020 16:22:16 +0200 Subject: gcc-changelog: handle entries with multi-line file lists This extends the ChangeLog entries parsing machinery to handle entries that cover multiple files spanning over multiple lines. For instance: * first_file_patched.c, second_file_patched.c, third_file_patched.c, fourth_file_patched.c: Do things. contrib/ * gcc-changelog/git_commit.py (ChangeLogEntry): Handle entries with multi-line file lists. * gcc-changelog/test_email.py: New testcase. * gcc-changelog/test_patches.txt: Likewise. --- contrib/gcc-changelog/git_commit.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'contrib/gcc-changelog/git_commit.py') diff --git a/contrib/gcc-changelog/git_commit.py b/contrib/gcc-changelog/git_commit.py index 6f99d91..a24a251 100755 --- a/contrib/gcc-changelog/git_commit.py +++ b/contrib/gcc-changelog/git_commit.py @@ -185,14 +185,32 @@ class ChangeLogEntry: @property def files(self): files = [] + + # Whether the content currently processed is between a star prefix the + # end of the file list: a colon or an open paren. + in_location = False + for line in self.lines: + # If this line matches the star prefix, start the location + # processing on the information that follows the star. m = star_prefix_regex.match(line) if m: + in_location = True line = m.group('content') + + if in_location: + # Strip everything that is not a filename in "line": entities + # "(NAME)", entry text (the colon, if present, and anything + # that follows it). if '(' in line: line = line[:line.index('(')] + in_location = False if ':' in line: line = line[:line.index(':')] + in_location = False + + # At this point, all that 's left is a list of filenames + # separated by commas and whitespaces. for file in line.split(','): file = file.strip() if file: -- cgit v1.1