@@ -1523,6 +1523,120 @@ def test_changelog_template_extras_precedance(
15231523 assert changelog .read_text () == "from-command - from-config - from-plugin"
15241524
15251525
1526+ @pytest .mark .usefixtures ("tmp_commitizen_project" )
1527+ @pytest .mark .freeze_time ("2021-06-11" )
1528+ def test_changelog_only_tag_matching_tag_format_included_prefix (
1529+ mocker : MockFixture ,
1530+ changelog_path : Path ,
1531+ config_path : Path ,
1532+ ):
1533+ with open (config_path , "a" , encoding = "utf-8" ) as f :
1534+ f .write ('\n tag_format = "custom${version}"\n ' )
1535+ create_file_and_commit ("feat: new file" )
1536+ git .tag ("v0.2.0" )
1537+ create_file_and_commit ("feat: another new file" )
1538+ git .tag ("0.2.0" )
1539+ git .tag ("random0.2.0" )
1540+ testargs = ["cz" , "bump" , "--changelog" , "--yes" ]
1541+ mocker .patch .object (sys , "argv" , testargs )
1542+ cli .main ()
1543+ wait_for_tag ()
1544+ create_file_and_commit ("feat: another new file" )
1545+ cli .main ()
1546+ with open (changelog_path ) as f :
1547+ out = f .read ()
1548+ assert out .startswith ("## custom0.3.0 (2021-06-11)" )
1549+ assert "## v0.2.0 (2021-06-11)" not in out
1550+ assert "## 0.2.0 (2021-06-11)" not in out
1551+
1552+
1553+ @pytest .mark .usefixtures ("tmp_commitizen_project" )
1554+ def test_changelog_only_tag_matching_tag_format_included_prefix_sep (
1555+ mocker : MockFixture ,
1556+ changelog_path : Path ,
1557+ config_path : Path ,
1558+ ):
1559+ with open (config_path , "a" , encoding = "utf-8" ) as f :
1560+ f .write ('\n tag_format = "custom-${version}"\n ' )
1561+ create_file_and_commit ("feat: new file" )
1562+ git .tag ("v0.2.0" )
1563+ create_file_and_commit ("feat: another new file" )
1564+ git .tag ("0.2.0" )
1565+ git .tag ("random0.2.0" )
1566+ wait_for_tag ()
1567+ testargs = ["cz" , "bump" , "--changelog" , "--yes" ]
1568+ mocker .patch .object (sys , "argv" , testargs )
1569+ cli .main ()
1570+ with open (changelog_path ) as f :
1571+ out = f .read ()
1572+ create_file_and_commit ("feat: new version another new file" )
1573+ create_file_and_commit ("feat: new version some new file" )
1574+ testargs = ["cz" , "bump" , "--changelog" ]
1575+ mocker .patch .object (sys , "argv" , testargs )
1576+ cli .main ()
1577+ with open (changelog_path ) as f :
1578+ out = f .read ()
1579+ assert out .startswith ("## custom-0.3.0" )
1580+ assert "## v0.2.0" not in out
1581+ assert "## 0.2.0" not in out
1582+
1583+
1584+ @pytest .mark .usefixtures ("tmp_commitizen_project" )
1585+ @pytest .mark .freeze_time ("2021-06-11" )
1586+ def test_changelog_only_tag_matching_tag_format_included_suffix (
1587+ mocker : MockFixture ,
1588+ changelog_path : Path ,
1589+ config_path : Path ,
1590+ ):
1591+ with open (config_path , "a" , encoding = "utf-8" ) as f :
1592+ f .write ('\n tag_format = "${version}custom"\n ' )
1593+ create_file_and_commit ("feat: new file" )
1594+ git .tag ("v0.2.0" )
1595+ create_file_and_commit ("feat: another new file" )
1596+ git .tag ("0.2.0" )
1597+ git .tag ("random0.2.0" )
1598+ testargs = ["cz" , "bump" , "--changelog" , "--yes" ]
1599+ mocker .patch .object (sys , "argv" , testargs )
1600+ cli .main ()
1601+ wait_for_tag ()
1602+ create_file_and_commit ("feat: another new file" )
1603+ cli .main ()
1604+ wait_for_tag ()
1605+ with open (changelog_path ) as f :
1606+ out = f .read ()
1607+ assert out .startswith ("## 0.3.0custom (2021-06-11)" )
1608+ assert "## v0.2.0 (2021-06-11)" not in out
1609+ assert "## 0.2.0 (2021-06-11)" not in out
1610+
1611+
1612+ @pytest .mark .usefixtures ("tmp_commitizen_project" )
1613+ @pytest .mark .freeze_time ("2021-06-11" )
1614+ def test_changelog_only_tag_matching_tag_format_included_suffix_sep (
1615+ mocker : MockFixture ,
1616+ changelog_path : Path ,
1617+ config_path : Path ,
1618+ ):
1619+ with open (config_path , "a" , encoding = "utf-8" ) as f :
1620+ f .write ('\n tag_format = "${version}-custom"\n ' )
1621+ create_file_and_commit ("feat: new file" )
1622+ git .tag ("v0.2.0" )
1623+ create_file_and_commit ("feat: another new file" )
1624+ git .tag ("0.2.0" )
1625+ git .tag ("random0.2.0" )
1626+ testargs = ["cz" , "bump" , "--changelog" , "--yes" ]
1627+ mocker .patch .object (sys , "argv" , testargs )
1628+ cli .main ()
1629+ wait_for_tag ()
1630+ create_file_and_commit ("feat: another new file" )
1631+ cli .main ()
1632+ wait_for_tag ()
1633+ with open (changelog_path ) as f :
1634+ out = f .read ()
1635+ assert out .startswith ("## 0.3.0-custom (2021-06-11)" )
1636+ assert "## v0.2.0 (2021-06-11)" not in out
1637+ assert "## 0.2.0 (2021-06-11)" not in out
1638+
1639+
15261640def test_changelog_template_extra_quotes (
15271641 mocker : MockFixture ,
15281642 tmp_commitizen_project : Path ,
0 commit comments