From c24a1e86da80986b9bba00c462ff82a574b01f1b Mon Sep 17 00:00:00 2001 From: Paul Elliott Date: Fri, 5 Mar 2021 12:22:51 +0000 Subject: [PATCH 1/4] Make assemble changelog script enforce line length As I descovered, a changelog entry with a line length greater than 80 characters would still pass CI. This is a quick change to the script to make it detect these descrepancies and fail. Signed-off-by: Paul Elliott --- .../make_assemble_changelog_enforce_line_length.txt | 2 ++ scripts/assemble_changelog.py | 12 ++++++++++++ 2 files changed, 14 insertions(+) create mode 100644 ChangeLog.d/make_assemble_changelog_enforce_line_length.txt diff --git a/ChangeLog.d/make_assemble_changelog_enforce_line_length.txt b/ChangeLog.d/make_assemble_changelog_enforce_line_length.txt new file mode 100644 index 000000000..3baed0205 --- /dev/null +++ b/ChangeLog.d/make_assemble_changelog_enforce_line_length.txt @@ -0,0 +1,2 @@ +Changes + * Make assemble_changelog.py script enforce 80 character line limit diff --git a/scripts/assemble_changelog.py b/scripts/assemble_changelog.py index 02bae25b7..f85392c53 100755 --- a/scripts/assemble_changelog.py +++ b/scripts/assemble_changelog.py @@ -101,6 +101,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 @@ -241,6 +244,15 @@ class ChangeLog: line_offset + category.title_line, 'Unknown category: "{}"', category.name.decode('utf8')) + + body_split = category.body.splitlines() + for line in body_split: + if len(line) > MAX_LINE_LENGTH: + raise InputFormatError(filename, + line_offset + category.title_line, + 'Category body line too long: "{} ({})"', + category.name.decode('utf8'), len(line)) + self.categories[category.name] += category.body def __init__(self, input_stream, changelog_format): From 46bef5f9297e14d057f75b534f95818c44348132 Mon Sep 17 00:00:00 2001 From: Paul Elliott Date: Tue, 9 Mar 2021 10:23:18 +0000 Subject: [PATCH 2/4] Remove changelog entry Signed-off-by: Paul Elliott --- ChangeLog.d/make_assemble_changelog_enforce_line_length.txt | 2 -- 1 file changed, 2 deletions(-) delete mode 100644 ChangeLog.d/make_assemble_changelog_enforce_line_length.txt diff --git a/ChangeLog.d/make_assemble_changelog_enforce_line_length.txt b/ChangeLog.d/make_assemble_changelog_enforce_line_length.txt deleted file mode 100644 index 3baed0205..000000000 --- a/ChangeLog.d/make_assemble_changelog_enforce_line_length.txt +++ /dev/null @@ -1,2 +0,0 @@ -Changes - * Make assemble_changelog.py script enforce 80 character line limit From 217565ef4eaecddcae90bd554add8fb668050fda Mon Sep 17 00:00:00 2001 From: Paul Elliott Date: Tue, 9 Mar 2021 10:24:55 +0000 Subject: [PATCH 3/4] Improve error message Make sure line number reported is correct for the overly long line, and change the message to be more readable. Signed-off-by: Paul Elliott --- scripts/assemble_changelog.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/scripts/assemble_changelog.py b/scripts/assemble_changelog.py index f85392c53..96d2217a9 100755 --- a/scripts/assemble_changelog.py +++ b/scripts/assemble_changelog.py @@ -246,12 +246,14 @@ class ChangeLog: category.name.decode('utf8')) body_split = category.body.splitlines() + line_number = 1 for line in body_split: if len(line) > MAX_LINE_LENGTH: raise InputFormatError(filename, - line_offset + category.title_line, - 'Category body line too long: "{} ({})"', - category.name.decode('utf8'), len(line)) + line_offset + category.title_line + line_number, + 'Line is longer than allowed: Length {} (Max {})', + len(line), MAX_LINE_LENGTH) + line_number += 1 self.categories[category.name] += category.body From 0ec59794615e711d181c9df7fe02f7daf1d5332d Mon Sep 17 00:00:00 2001 From: Paul Elliott Date: Thu, 18 Mar 2021 18:07:46 +0000 Subject: [PATCH 4/4] Pythonify and fix reported line number Use enumerate to give the line number and use the correct offset to actually calculate it. Signed-off-by: Paul Elliott --- scripts/assemble_changelog.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/scripts/assemble_changelog.py b/scripts/assemble_changelog.py index 96d2217a9..2c9fc0b29 100755 --- a/scripts/assemble_changelog.py +++ b/scripts/assemble_changelog.py @@ -246,14 +246,12 @@ class ChangeLog: category.name.decode('utf8')) body_split = category.body.splitlines() - line_number = 1 - for line in body_split: + for line_number, line in enumerate(body_split, 1): if len(line) > MAX_LINE_LENGTH: raise InputFormatError(filename, - line_offset + category.title_line + line_number, + category.body_line + line_number, 'Line is longer than allowed: Length {} (Max {})', len(line), MAX_LINE_LENGTH) - line_number += 1 self.categories[category.name] += category.body