From 5bbcf545c897a42389f13d8bf92d18658880c80b Mon Sep 17 00:00:00 2001 From: Clement <114182330+css-optivoy@users.noreply.github.com> Date: Thu, 17 Nov 2022 21:19:42 +0100 Subject: [PATCH 1/2] Fixes changelog release commit search logic Running `semantic-release changelog` currently fails to identify "the last commit in [a] release" because the compared commit messages have superfluous whitespace. Likely related to the issue causing: https://github.com/relekang/python-semantic-release/issues/490 --- semantic_release/history/logs.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/semantic_release/history/logs.py b/semantic_release/history/logs.py index 6b0a5f7bc..17df5d21c 100644 --- a/semantic_release/history/logs.py +++ b/semantic_release/history/logs.py @@ -101,9 +101,12 @@ def generate_changelog( changes: dict = {"breaking": []} found_the_release = to_version is None - to_version_commit = to_version and get_formatted_commit(to_version) - from_version_commit = from_version and get_formatted_commit(from_version) + to_version_commit = to_version and get_formatted_commit(to_version).strip() + from_version_commit = from_version and get_formatted_commit(from_version).strip() for _hash, commit_message in get_commit_log(from_version, to_version): + # See https://github.com/relekang/python-semantic-release/issues/490 - + # commit messages (which we compare with ==) have a trailing newline + commit_message = commit_message.strip() if not found_the_release: # Skip until we find the last commit in this release # (we are looping in the order of newest -> oldest) @@ -115,8 +118,6 @@ def generate_changelog( ) found_the_release = True - # See https://github.com/relekang/python-semantic-release/issues/490 - - # commit messages (which we compare with ==) have a trailing newline if ( from_version_commit and commit_message.strip() == from_version_commit.strip() From 10d4800c6bd1221d5dde6439f27e00b3bb2d67e7 Mon Sep 17 00:00:00 2001 From: Clement <114182330+css-optivoy@users.noreply.github.com> Date: Fri, 18 Nov 2022 08:40:57 +0100 Subject: [PATCH 2/2] Removes a couple of extra `strip()`s. --- semantic_release/history/logs.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/semantic_release/history/logs.py b/semantic_release/history/logs.py index 17df5d21c..a390ee923 100644 --- a/semantic_release/history/logs.py +++ b/semantic_release/history/logs.py @@ -118,10 +118,7 @@ def generate_changelog( ) found_the_release = True - if ( - from_version_commit - and commit_message.strip() == from_version_commit.strip() - ): + if (from_version_commit and commit_message == from_version_commit): # We reached the previous release logger.debug(f"{from_version} reached, ending changelog generation") break