@@ -1692,3 +1692,66 @@ def test_is_initial_tag(mocker: MockFixture, tmp_commitizen_project):
16921692 # Test case 4: No current tag, user denies
16931693 mocker .patch ("questionary.confirm" , return_value = mocker .Mock (ask = lambda : False ))
16941694 assert bump_cmd ._is_initial_tag (None , is_yes = False ) is False
1695+
1696+
1697+ @pytest .mark .parametrize ("test_input" , ["rc" , "alpha" , "beta" ])
1698+ @pytest .mark .usefixtures ("tmp_commitizen_project" )
1699+ @pytest .mark .freeze_time ("2025-01-01" )
1700+ def test_changelog_config_flag_merge_prerelease (
1701+ mocker : MockFixture , changelog_path , config_path , file_regression , test_input
1702+ ):
1703+ with open (config_path , "a" ) as f :
1704+ f .write ("changelog_merge_prerelease = true\n " )
1705+ f .write ("update_changelog_on_bump = true\n " )
1706+ f .write ("annotated_tag = true\n " )
1707+
1708+ create_file_and_commit ("irrelevant commit" )
1709+ mocker .patch ("commitizen.git.GitTag.date" , "1970-01-01" )
1710+ git .tag ("0.1.0" )
1711+
1712+ create_file_and_commit ("feat: add new output" )
1713+ create_file_and_commit ("fix: output glitch" )
1714+ testargs = ["cz" , "bump" , "--prerelease" , test_input , "--yes" ]
1715+ mocker .patch .object (sys , "argv" , testargs )
1716+ cli .main ()
1717+
1718+ testargs = ["cz" , "bump" , "--changelog" ]
1719+ mocker .patch .object (sys , "argv" , testargs )
1720+ cli .main ()
1721+
1722+ with open (changelog_path ) as f :
1723+ out = f .read ()
1724+
1725+ file_regression .check (out , extension = ".md" )
1726+
1727+
1728+ @pytest .mark .parametrize ("test_input" , ["rc" , "alpha" , "beta" ])
1729+ @pytest .mark .usefixtures ("tmp_commitizen_project" )
1730+ @pytest .mark .freeze_time ("2025-01-01" )
1731+ def test_changelog_config_flag_merge_prerelease_only_prerelease_present (
1732+ mocker : MockFixture , changelog_path , config_path , file_regression , test_input
1733+ ):
1734+ with open (config_path , "a" ) as f :
1735+ f .write ("changelog_merge_prerelease = true\n " )
1736+ f .write ("update_changelog_on_bump = true\n " )
1737+ f .write ("annotated_tag = true\n " )
1738+
1739+ create_file_and_commit ("feat: more relevant commit" )
1740+ testargs = ["cz" , "bump" , "--prerelease" , test_input , "--yes" ]
1741+ mocker .patch .object (sys , "argv" , testargs )
1742+ cli .main ()
1743+
1744+ create_file_and_commit ("feat: add new output" )
1745+ create_file_and_commit ("fix: output glitch" )
1746+ testargs = ["cz" , "bump" , "--prerelease" , test_input , "--yes" ]
1747+ mocker .patch .object (sys , "argv" , testargs )
1748+ cli .main ()
1749+
1750+ testargs = ["cz" , "bump" , "--changelog" ]
1751+ mocker .patch .object (sys , "argv" , testargs )
1752+ cli .main ()
1753+
1754+ with open (changelog_path ) as f :
1755+ out = f .read ()
1756+
1757+ file_regression .check (out , extension = ".md" )
0 commit comments