Skip to content

Commit efb3410

Browse files
authored
fix: changelog release commit search logic (python-semantic-release#530)
* 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: python-semantic-release#490 * Removes a couple of extra `strip()`s.
1 parent 8f2185d commit efb3410

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

semantic_release/history/logs.py

+6-8
Original file line numberDiff line numberDiff line change
@@ -101,9 +101,12 @@ def generate_changelog(
101101
changes: dict = {"breaking": []}
102102

103103
found_the_release = to_version is None
104-
to_version_commit = to_version and get_formatted_commit(to_version)
105-
from_version_commit = from_version and get_formatted_commit(from_version)
104+
to_version_commit = to_version and get_formatted_commit(to_version).strip()
105+
from_version_commit = from_version and get_formatted_commit(from_version).strip()
106106
for _hash, commit_message in get_commit_log(from_version, to_version):
107+
# See https://github.com/relekang/python-semantic-release/issues/490 -
108+
# commit messages (which we compare with ==) have a trailing newline
109+
commit_message = commit_message.strip()
107110
if not found_the_release:
108111
# Skip until we find the last commit in this release
109112
# (we are looping in the order of newest -> oldest)
@@ -115,12 +118,7 @@ def generate_changelog(
115118
)
116119
found_the_release = True
117120

118-
# See https://github.com/relekang/python-semantic-release/issues/490 -
119-
# commit messages (which we compare with ==) have a trailing newline
120-
if (
121-
from_version_commit
122-
and commit_message.strip() == from_version_commit.strip()
123-
):
121+
if (from_version_commit and commit_message == from_version_commit):
124122
# We reached the previous release
125123
logger.debug(f"{from_version} reached, ending changelog generation")
126124
break

0 commit comments

Comments
 (0)