Merge pull request #4202 from paul-elliott-arm/changelog_linelength_enforcement

Make assemble changelog script enforce line length
This commit is contained in:
Ronald Cron 2021-03-19 12:26:31 +01:00 committed by GitHub
commit 5cb08a8e61
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -74,6 +74,9 @@ STANDARD_CATEGORIES = (
b'Changes',
)
# The maximum line length for an entry
MAX_LINE_LENGTH = 80
CategoryContent = namedtuple('CategoryContent', [
'name', 'title_line', # Title text and line number of the title
'body', 'body_line', # Body text and starting line number of the body
@ -214,6 +217,15 @@ class ChangeLog:
line_offset + category.title_line,
'Unknown category: "{}"',
category.name.decode('utf8'))
body_split = category.body.splitlines()
for line_number, line in enumerate(body_split, 1):
if len(line) > MAX_LINE_LENGTH:
raise InputFormatError(filename,
category.body_line + line_number,
'Line is longer than allowed: Length {} (Max {})',
len(line), MAX_LINE_LENGTH)
self.categories[category.name] += category.body
def __init__(self, input_stream, changelog_format):