Skip to content

Commit c89218b

Browse files
committed
test(changelog): handle custom tag_format in changelog generation
1 parent cf69409 commit c89218b

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

Diff for: tests/commands/test_changelog_command.py

+25
Original file line numberDiff line numberDiff line change
@@ -1522,6 +1522,31 @@ def test_changelog_template_extras_precedance(
15221522
assert changelog.read_text() == "from-command - from-config - from-plugin"
15231523

15241524

1525+
@pytest.mark.usefixtures("tmp_commitizen_project")
1526+
@pytest.mark.freeze_time("2021-06-11")
1527+
def test_changelog_only_tag_matching_tag_format_included(
1528+
mocker: MockFixture,
1529+
changelog_path: Path,
1530+
config_path: Path,
1531+
):
1532+
with open(config_path, "a", encoding="utf-8") as f:
1533+
f.write('\ntag_format = "${version}custom"\n')
1534+
create_file_and_commit("feat: new file")
1535+
git.tag("v0.2.0")
1536+
create_file_and_commit("feat: another new file")
1537+
git.tag("0.2.0")
1538+
git.tag("random0.2.0")
1539+
testargs = ["cz", "bump", "--changelog", "--yes"]
1540+
mocker.patch.object(sys, "argv", testargs)
1541+
cli.main()
1542+
wait_for_tag()
1543+
with open(changelog_path) as f:
1544+
out = f.read()
1545+
assert out.startswith("## 0.2.0custom (2021-06-11)")
1546+
assert "## v0.2.0 (2021-06-11)" not in out
1547+
assert "## 0.2.0 (2021-06-11)" not in out
1548+
1549+
15251550
def test_changelog_template_extra_quotes(
15261551
mocker: MockFixture,
15271552
tmp_commitizen_project: Path,

0 commit comments

Comments
 (0)