Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 0a89510

Browse files
test(changelog): handle custom tag_format in changelog generation
1 parent d5f127d commit 0a89510

File tree

1 file changed

+114
-0
lines changed

1 file changed

+114
-0
lines changed

‎tests/commands/test_changelog_command.py‎

Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1522,6 +1522,120 @@ 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_prefix(
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 = "custom${version}"\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+
create_file_and_commit("feat: another new file")
1544+
cli.main()
1545+
with open(changelog_path) as f:
1546+
out = f.read()
1547+
assert out.startswith("## custom0.3.0 (2021年06月11日)")
1548+
assert "## v0.2.0 (2021年06月11日)" not in out
1549+
assert "## 0.2.0 (2021年06月11日)" not in out
1550+
1551+
1552+
@pytest.mark.usefixtures("tmp_commitizen_project")
1553+
def test_changelog_only_tag_matching_tag_format_included_prefix_sep(
1554+
mocker: MockFixture,
1555+
changelog_path: Path,
1556+
config_path: Path,
1557+
):
1558+
with open(config_path, "a", encoding="utf-8") as f:
1559+
f.write('\ntag_format = "custom-${version}"\n')
1560+
create_file_and_commit("feat: new file")
1561+
git.tag("v0.2.0")
1562+
create_file_and_commit("feat: another new file")
1563+
git.tag("0.2.0")
1564+
git.tag("random0.2.0")
1565+
wait_for_tag()
1566+
testargs = ["cz", "bump", "--changelog", "--yes"]
1567+
mocker.patch.object(sys, "argv", testargs)
1568+
cli.main()
1569+
with open(changelog_path) as f:
1570+
out = f.read()
1571+
create_file_and_commit("feat: new version another new file")
1572+
create_file_and_commit("feat: new version some new file")
1573+
testargs = ["cz", "bump", "--changelog"]
1574+
mocker.patch.object(sys, "argv", testargs)
1575+
cli.main()
1576+
with open(changelog_path) as f:
1577+
out = f.read()
1578+
assert out.startswith("## custom-0.3.0")
1579+
assert "## v0.2.0" not in out
1580+
assert "## 0.2.0" not in out
1581+
1582+
1583+
@pytest.mark.usefixtures("tmp_commitizen_project")
1584+
@pytest.mark.freeze_time("2021年06月11日")
1585+
def test_changelog_only_tag_matching_tag_format_included_suffix(
1586+
mocker: MockFixture,
1587+
changelog_path: Path,
1588+
config_path: Path,
1589+
):
1590+
with open(config_path, "a", encoding="utf-8") as f:
1591+
f.write('\ntag_format = "${version}custom"\n')
1592+
create_file_and_commit("feat: new file")
1593+
git.tag("v0.2.0")
1594+
create_file_and_commit("feat: another new file")
1595+
git.tag("0.2.0")
1596+
git.tag("random0.2.0")
1597+
testargs = ["cz", "bump", "--changelog", "--yes"]
1598+
mocker.patch.object(sys, "argv", testargs)
1599+
cli.main()
1600+
wait_for_tag()
1601+
create_file_and_commit("feat: another new file")
1602+
cli.main()
1603+
wait_for_tag()
1604+
with open(changelog_path) as f:
1605+
out = f.read()
1606+
assert out.startswith("## 0.3.0custom (2021年06月11日)")
1607+
assert "## v0.2.0 (2021年06月11日)" not in out
1608+
assert "## 0.2.0 (2021年06月11日)" not in out
1609+
1610+
1611+
@pytest.mark.usefixtures("tmp_commitizen_project")
1612+
@pytest.mark.freeze_time("2021年06月11日")
1613+
def test_changelog_only_tag_matching_tag_format_included_suffix_sep(
1614+
mocker: MockFixture,
1615+
changelog_path: Path,
1616+
config_path: Path,
1617+
):
1618+
with open(config_path, "a", encoding="utf-8") as f:
1619+
f.write('\ntag_format = "${version}-custom"\n')
1620+
create_file_and_commit("feat: new file")
1621+
git.tag("v0.2.0")
1622+
create_file_and_commit("feat: another new file")
1623+
git.tag("0.2.0")
1624+
git.tag("random0.2.0")
1625+
testargs = ["cz", "bump", "--changelog", "--yes"]
1626+
mocker.patch.object(sys, "argv", testargs)
1627+
cli.main()
1628+
wait_for_tag()
1629+
create_file_and_commit("feat: another new file")
1630+
cli.main()
1631+
wait_for_tag()
1632+
with open(changelog_path) as f:
1633+
out = f.read()
1634+
assert out.startswith("## 0.3.0-custom (2021年06月11日)")
1635+
assert "## v0.2.0 (2021年06月11日)" not in out
1636+
assert "## 0.2.0 (2021年06月11日)" not in out
1637+
1638+
15251639
def test_changelog_template_extra_quotes(
15261640
mocker: MockFixture,
15271641
tmp_commitizen_project: Path,

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /