diff options
Diffstat (limited to 'contrib/gcc-changelog/git_commit.py')
-rwxr-xr-x | contrib/gcc-changelog/git_commit.py | 32 |
1 files changed, 30 insertions, 2 deletions
diff --git a/contrib/gcc-changelog/git_commit.py b/contrib/gcc-changelog/git_commit.py index 59f4786..e9dae0a 100755 --- a/contrib/gcc-changelog/git_commit.py +++ b/contrib/gcc-changelog/git_commit.py @@ -214,6 +214,7 @@ class ChangeLogEntry: self.lines = [] self.files = [] self.file_patterns = [] + self.opened_parentheses = 0 def parse_file_names(self): # Whether the content currently processed is between a star prefix the @@ -223,8 +224,14 @@ class ChangeLogEntry: for line in self.lines: # If this line matches the star prefix, start the location # processing on the information that follows the star. + # Note that we need to skip macro names that can be in form of: + # + # * config/i386/i386.md (*fix_trunc<mode>_i387_1, + # *add<mode>3_ne, *add<mode>3_eq_0, *add<mode>3_ne_0, + # *fist<mode>2_<rounding>_1, *<code><mode>3_1): + # m = star_prefix_regex.match(line) - if m: + if m and len(m.group('spaces')) == 1: in_location = True line = m.group('content') @@ -328,6 +335,7 @@ class GitCommit: self.parse_changelog() self.parse_file_names() self.check_for_empty_description() + self.check_for_broken_parentheses() self.deduce_changelog_locations() self.check_file_patterns() if not self.errors: @@ -496,7 +504,8 @@ class GitCommit: else: m = star_prefix_regex.match(line) if m: - if len(m.group('spaces')) != 1: + if (len(m.group('spaces')) != 1 and + last_entry.opened_parentheses == 0): msg = 'one space should follow asterisk' self.errors.append(Error(msg, line)) else: @@ -508,6 +517,7 @@ class GitCommit: msg = f'empty group "{needle}" found' self.errors.append(Error(msg, line)) last_entry.lines.append(line) + self.process_parentheses(last_entry, line) else: if last_entry.is_empty: msg = 'first line should start with a tab, ' \ @@ -515,6 +525,18 @@ class GitCommit: self.errors.append(Error(msg, line)) else: last_entry.lines.append(line) + self.process_parentheses(last_entry, line) + + def process_parentheses(self, last_entry, line): + for c in line: + if c == '(': + last_entry.opened_parentheses += 1 + elif c == ')': + if last_entry.opened_parentheses == 0: + msg = 'bad wrapping of parenthesis' + self.errors.append(Error(msg, line)) + else: + last_entry.opened_parentheses -= 1 def parse_file_names(self): for entry in self.changelog_entries: @@ -538,6 +560,12 @@ class GitCommit: msg = 'missing description of a change' self.errors.append(Error(msg, line)) + def check_for_broken_parentheses(self): + for entry in self.changelog_entries: + if entry.opened_parentheses != 0: + msg = 'bad parentheses wrapping' + self.errors.append(Error(msg, entry.lines[0])) + def get_file_changelog_location(self, changelog_file): for file in self.info.modified_files: if file[0] == changelog_file: |