Skip to content

Commit

Permalink
gitchangelog: don't break lines on hyphens in relnotes
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
nicki-krizek committed Dec 2, 2024
1 parent cd31229 commit 9b0d0c0
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions contrib/gitchangelog/gitchangelog.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()


Expand Down Expand Up @@ -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"])
Expand Down

0 comments on commit 9b0d0c0

Please sign in to comment.