From 9b0d0c017315c0850cde5df95609d1d0982c784f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicki=20K=C5=99=C3=AD=C5=BEek?= Date: Mon, 2 Dec 2024 11:10:01 +0100 Subject: [PATCH] gitchangelog: don't break lines on hyphens in relnotes When release notes are generated, the text is wrapped and line breaks are inserted into each paragraph (sourced from the commit message's body). Prevent line breaks after hyphens, as these are often used for option names. This makes it possible to easily find the options afterwards. --- contrib/gitchangelog/gitchangelog.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/contrib/gitchangelog/gitchangelog.py b/contrib/gitchangelog/gitchangelog.py index b466c38c70..7d22fe483d 100755 --- a/contrib/gitchangelog/gitchangelog.py +++ b/contrib/gitchangelog/gitchangelog.py @@ -561,7 +561,8 @@ def paragraph_wrap(text, regexp="\n\n", separator="\n"): """ regexp = re.compile(regexp, re.MULTILINE) return separator.join( - "\n".join(textwrap.wrap(paragraph.strip())) for paragraph in regexp.split(text) + "\n".join(textwrap.wrap(paragraph.strip(), break_on_hyphens=False)) + for paragraph in regexp.split(text) ).strip() @@ -1514,7 +1515,12 @@ def render_commit(commit, opts=opts): if opts["include_commit_sha"]: subject += " ``%s``" % commit["commit"].sha1_short - entry = indent("\n".join(textwrap.wrap(subject)), first="- ").strip() + "\n" + entry = ( + indent( + "\n".join(textwrap.wrap(subject, break_on_hyphens=False)), first="- " + ).strip() + + "\n" + ) if commit["body"]: entry += "\n" + indent(commit["body"])