Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions src/semantic_release/changelog/release_history.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ def from_git_history(

released.setdefault(the_version, release)

logger.info(
logger.debug(
"parsing commit [%s] %s",
commit.hexsha[:8],
str(commit.message).replace("\n", " ")[:54],
Expand Down Expand Up @@ -164,15 +164,15 @@ def from_git_history(
)

if ignore_merge_commits and parsed_result.is_merge_commit():
logger.info("Excluding merge commit[%s]", parsed_result.short_hash)
logger.debug("Excluding merge commit[%s]", parsed_result.short_hash)
continue

# Skip excluded commits except for any commit causing a version bump
# Reasoning: if a commit causes a version bump, and no other commits
# are included, then the changelog will be empty. Even if ther was other
# commits included, the true reason for a version bump would be missing.
if has_exclusion_match and commit_level_bump == LevelBump.NO_RELEASE:
logger.info(
logger.debug(
"Excluding %s commit[%s] %s",
"piece of squashed" if is_squash_commit else "",
parsed_result.short_hash,
Expand All @@ -184,7 +184,7 @@ def from_git_history(
isinstance(parsed_result, ParsedCommit)
and not parsed_result.include_in_changelog
):
logger.info(
logger.debug(
str.join(
" ",
[
Expand All @@ -197,15 +197,15 @@ def from_git_history(
continue

if the_version is None:
logger.info(
logger.debug(
"[Unreleased] adding commit[%s] to unreleased '%s'",
parsed_result.short_hash,
commit_type,
)
unreleased[commit_type].append(parsed_result)
continue

logger.info(
logger.debug(
"[%s] adding commit[%s] to release '%s'",
the_version,
parsed_result.short_hash,
Expand Down
41 changes: 41 additions & 0 deletions tests/unit/semantic_release/changelog/test_release_history.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
from __future__ import annotations

import logging
import re
from datetime import datetime
from typing import TYPE_CHECKING, NamedTuple

Expand All @@ -8,6 +10,7 @@
from pytest_lazy_fixtures.lazy_fixture import lf as lazy_fixture

from semantic_release.changelog.release_history import ReleaseHistory
from semantic_release.globals import logger
from semantic_release.version.translator import VersionTranslator
from semantic_release.version.version import Version

Expand Down Expand Up @@ -302,3 +305,41 @@ def test_all_matching_repo_tags_are_released(

for tag in repo.tags:
assert translator.from_tag(tag.name) in release_history.released


@pytest.mark.order("last")
def test_release_history_commit_details_are_debug_logs(
repo_w_no_tags_conventional_commits: BuiltRepoResult,
default_conventional_parser: ConventionalCommitParser,
caplog: pytest.LogCaptureFixture,
):
with caplog.at_level(logging.DEBUG, logger=logger.name):
ReleaseHistory.from_git_history(
repo=repo_w_no_tags_conventional_commits["repo"],
translator=VersionTranslator(),
commit_parser=default_conventional_parser, # type: ignore[arg-type]
exclude_commit_patterns=(re.compile(r"^Initial commit"),),
)

commit_detail_records = [
record
for record in caplog.records
if any(
message in record.getMessage()
for message in ("parsing commit", "Excluding", "adding commit")
)
]

assert commit_detail_records
assert any(
"parsing commit" in record.getMessage() for record in commit_detail_records
)
assert any("Excluding" in record.getMessage() for record in commit_detail_records)
assert any(
"adding commit" in record.getMessage() for record in commit_detail_records
)
assert all(record.levelno == logging.DEBUG for record in commit_detail_records)
assert any(
record.levelno == logging.INFO and "previous tags" in record.getMessage()
for record in caplog.records
)