aboutsummaryrefslogtreecommitdiff
path: root/contrib/mklog.py
diff options
context:
space:
mode:
authorMartin Liska <mliska@suse.cz>2021-06-28 13:08:10 +0200
committerMartin Liska <mliska@suse.cz>2021-06-28 13:43:41 +0200
commitb838641bb0d4de5b25128b54012155ab46f452d0 (patch)
treec73b2144139c1f89eedec57bd6ae50dd0d7a06f1 /contrib/mklog.py
parent9fe9c45ae33a2df7a73a7c8d9a92a649206a15b7 (diff)
downloadgcc-b838641bb0d4de5b25128b54012155ab46f452d0.zip
gcc-b838641bb0d4de5b25128b54012155ab46f452d0.tar.gz
gcc-b838641bb0d4de5b25128b54012155ab46f452d0.tar.bz2
mklog: Handle correctly long lines.
contrib/ChangeLog: * mklog.py: Handle correctly long lines. * test_mklog.py: Test it.
Diffstat (limited to 'contrib/mklog.py')
-rwxr-xr-xcontrib/mklog.py22
1 files changed, 18 insertions, 4 deletions
diff --git a/contrib/mklog.py b/contrib/mklog.py
index 674c1dc..ba70af0 100755
--- a/contrib/mklog.py
+++ b/contrib/mklog.py
@@ -38,6 +38,9 @@ import requests
from unidiff import PatchSet
+LINE_LIMIT = 100
+TAB_WIDTH = 8
+
pr_regex = re.compile(r'(\/(\/|\*)|[Cc*!])\s+(?P<pr>PR [a-z+-]+\/[0-9]+)')
prnum_regex = re.compile(r'PR (?P<comp>[a-z+-]+)/(?P<num>[0-9]+)')
dr_regex = re.compile(r'(\/(\/|\*)|[Cc*!])\s+(?P<dr>DR [0-9]+)')
@@ -134,6 +137,16 @@ def get_pr_titles(prs):
return '\n'.join(output)
+def append_changelog_line(out, relative_path, text):
+ line = f'\t* {relative_path}:'
+ if len(line.replace('\t', ' ' * TAB_WIDTH) + ' ' + text) <= LINE_LIMIT:
+ out += f'{line} {text}\n'
+ else:
+ out += f'{line}\n'
+ out += f'\t{text}\n'
+ return out
+
+
def generate_changelog(data, no_functions=False, fill_pr_titles=False,
additional_prs=None):
changelogs = {}
@@ -213,12 +226,12 @@ def generate_changelog(data, no_functions=False, fill_pr_titles=False,
relative_path = file.path[len(changelog):].lstrip('/')
functions = []
if file.is_added_file:
- msg = 'New test' if in_tests else 'New file'
- out += '\t* %s: %s.\n' % (relative_path, msg)
+ msg = 'New test.' if in_tests else 'New file.'
+ out = append_changelog_line(out, relative_path, msg)
elif file.is_removed_file:
- out += '\t* %s: Removed.\n' % (relative_path)
+ out = append_changelog_line(out, relative_path, 'Removed.')
elif hasattr(file, 'is_rename') and file.is_rename:
- out += '\t* %s: Moved to...\n' % (relative_path)
+ out = append_changelog_line(out, relative_path, 'Moved to...')
new_path = file.target_file[2:]
# A file can be theoretically moved to a location that
# belongs to a different ChangeLog. Let user fix it.
@@ -227,6 +240,7 @@ def generate_changelog(data, no_functions=False, fill_pr_titles=False,
out += '\t* %s: ...here.\n' % (new_path)
elif os.path.basename(file.path) in generated_files:
out += '\t* %s: Regenerate.\n' % (relative_path)
+ append_changelog_line(out, relative_path, 'Regenerate.')
else:
if not no_functions:
for hunk in file: