Skip to content

Commit 292feb4

Browse files
test(changelog): cover changelog_subject_only config wiring
Add an end-to-end test that sets `changelog_subject_only = true` in the project configuration, creates a commit with a parser-matching block in its body, and asserts that `cz changelog --dry-run` only emits the subject entry. Catches typos in the setting key at `commands/changelog.py:279` (which would otherwise silently fall back to `False`); manually verified by injecting a typo, observing the test fail with KeyError, then restoring. Addresses the only review finding from PR #1974. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 591fc33 commit 292feb4

1 file changed

Lines changed: 26 additions & 0 deletions

File tree

tests/commands/test_changelog_command.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,32 @@ def test_changelog_with_different_cz(
8787
file_regression.check(out, extension=".md")
8888

8989

90+
@pytest.mark.usefixtures("tmp_commitizen_project")
91+
def test_changelog_subject_only_setting_skips_body_parsing(
92+
util: UtilFixture,
93+
config_path: Path,
94+
capsys: pytest.CaptureFixture,
95+
):
96+
"""End-to-end coverage for `changelog_subject_only` (#1267 / #1974).
97+
98+
Verifies the config-key wiring in `commands/changelog.py`: when the
99+
setting is `true`, parser-matching blocks in commit bodies are
100+
ignored. Catches regressions where the setting key is mistyped or
101+
not propagated to `generate_tree_from_commits`.
102+
"""
103+
with config_path.open("a") as f:
104+
f.write("changelog_subject_only = true\n")
105+
106+
util.create_file_and_commit("feat: add new output\n\nrefactor: incidental cleanup")
107+
108+
with pytest.raises(DryRunExit):
109+
util.run_cli("changelog", "--dry-run")
110+
out, _ = capsys.readouterr()
111+
112+
assert "add new output" in out
113+
assert "incidental cleanup" not in out
114+
115+
90116
@pytest.mark.usefixtures("tmp_commitizen_project")
91117
def test_changelog_from_start(
92118
changelog_format: ChangelogFormat,

0 commit comments

Comments
 (0)