Skip to content

Commit

Permalink
fix(util): properly parse windows line-endings in commit messages
Browse files Browse the repository at this point in the history
Due to windows line-endings `\r\n`, it would improperly split the commit
description (it failed to split at all) and cause detection of Breaking changes
to fail. The breaking changes regular expression looks to the start of the line
for the proper syntax.

Resolves: #820
  • Loading branch information
codejedi365 authored and relekang committed Feb 8, 2024
1 parent c57b082 commit 70193ba
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions semantic_release/commit_parser/util.py
Expand Up @@ -9,11 +9,14 @@ def parse_paragraphs(text: str) -> list[str]:
"""
This will take a text block and return a list containing each
paragraph with single line breaks collapsed into spaces.
To handle Windows line endings, carriage returns '\r' are removed before
separating into paragraphs.
:param text: The text string to be divided.
:return: A list of condensed paragraphs, as strings.
"""
return [
paragraph.replace("\n", " ")
for paragraph in text.split("\n\n")
if len(paragraph) > 0
]
return list(filter(None, [
paragraph.replace("\n", " ").strip()
for paragraph in text.replace("\r", "").split("\n\n")
]))

0 comments on commit 70193ba

Please sign in to comment.