From 75d5d30d4cf8ebb910c375dc22313060f85e895f Mon Sep 17 00:00:00 2001 From: William Yardley Date: Fri, 14 Jun 2024 23:06:14 -0700 Subject: [PATCH] fix(commit_parser): strip DOS carriage-returns in commits The default template can result in mixed (UNIX / DOS style) carriage returns in the generated changelog. Use a string replace in the commit parser to strip the DOS CRs ("\r"). This is only needed in the case when we are _not_ byte decoding. Fixes #955 --- semantic_release/commit_parser/token.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/semantic_release/commit_parser/token.py b/semantic_release/commit_parser/token.py index 2536c8ebb..dab774f58 100644 --- a/semantic_release/commit_parser/token.py +++ b/semantic_release/commit_parser/token.py @@ -21,7 +21,8 @@ class ParsedCommit(NamedTuple): @property def message(self) -> str: m = self.commit.message - return m.decode("utf-8") if isinstance(m, bytes) else m + message_str = m.decode("utf-8") if isinstance(m, bytes) else m + return message_str.replace("\r", "") @property def hexsha(self) -> str: @@ -39,7 +40,8 @@ class ParseError(NamedTuple): @property def message(self) -> str: m = self.commit.message - return m.decode("utf-8") if isinstance(m, bytes) else m + message_str = m.decode("utf-8") if isinstance(m, bytes) else m + return message_str.replace("\r", "") @property def hexsha(self) -> str: