@@ -1502,3 +1502,89 @@ def test_bump_deprecate_files_only(util: UtilFixture):
15021502 pytest .raises (ExpectedExit ),
15031503 ):
15041504 util .run_cli ("bump" , "--yes" , "--files-only" )
1505+
1506+
1507+ @pytest .mark .usefixtures ("tmp_commitizen_project" )
1508+ def test_bump_changelog_incremental_default_not_set (
1509+ util : UtilFixture , changelog_path : Path , config_path : Path
1510+ ):
1511+ with config_path .open ("a" , encoding = "utf-8" ) as fp :
1512+ fp .write ("update_changelog_on_bump = true\n " )
1513+
1514+ util .create_file_and_commit ("feat(user): new user" )
1515+ util .run_cli ("bump" , "--yes" )
1516+ assert git .tag_exist ("0.2.0" ) is True
1517+
1518+ with changelog_path .open (encoding = "utf-8" ) as f :
1519+ content = f .read ()
1520+ with changelog_path .open ("w" , encoding = "utf-8" ) as f :
1521+ f .write (content .replace ("- **user**: new user" , "- **user**: new user\n \n MANUAL NOTE" ))
1522+ util .create_file_and_commit ("docs: add manual note to changelog" )
1523+
1524+ util .create_file_and_commit ("feat(admin): new admin" )
1525+ util .run_cli ("bump" , "--yes" )
1526+ assert git .tag_exist ("0.3.0" ) is True
1527+
1528+ with changelog_path .open (encoding = "utf-8" ) as f :
1529+ out = f .read ()
1530+ assert "0.3.0" in out
1531+ assert "0.2.0" in out
1532+ assert "MANUAL NOTE" in out
1533+
1534+
1535+ @pytest .mark .usefixtures ("tmp_commitizen_project" )
1536+ def test_bump_changelog_incremental_set_true (
1537+ util : UtilFixture , changelog_path : Path , config_path : Path
1538+ ):
1539+ with config_path .open ("a" , encoding = "utf-8" ) as fp :
1540+ fp .write ("update_changelog_on_bump = true\n " )
1541+ fp .write ("changelog_incremental = true\n " )
1542+
1543+ util .create_file_and_commit ("feat(user): new user" )
1544+ util .run_cli ("bump" , "--yes" )
1545+ assert git .tag_exist ("0.2.0" ) is True
1546+
1547+ with changelog_path .open (encoding = "utf-8" ) as f :
1548+ content = f .read ()
1549+ with changelog_path .open ("w" , encoding = "utf-8" ) as f :
1550+ f .write (content .replace ("- **user**: new user" , "- **user**: new user\n \n MANUAL NOTE" ))
1551+ util .create_file_and_commit ("docs: add manual note to changelog" )
1552+
1553+ util .create_file_and_commit ("feat(admin): new admin" )
1554+ util .run_cli ("bump" , "--yes" )
1555+ assert git .tag_exist ("0.3.0" ) is True
1556+
1557+ with changelog_path .open (encoding = "utf-8" ) as f :
1558+ out = f .read ()
1559+ assert "0.3.0" in out
1560+ assert "0.2.0" in out
1561+ assert "MANUAL NOTE" in out
1562+
1563+
1564+ @pytest .mark .usefixtures ("tmp_commitizen_project" )
1565+ def test_bump_changelog_incremental_set_false (
1566+ util : UtilFixture , changelog_path : Path , config_path : Path
1567+ ):
1568+ with config_path .open ("a" , encoding = "utf-8" ) as fp :
1569+ fp .write ("update_changelog_on_bump = true\n " )
1570+ fp .write ("changelog_incremental = false\n " )
1571+
1572+ util .create_file_and_commit ("feat(user): new user" )
1573+ util .run_cli ("bump" , "--yes" )
1574+ assert git .tag_exist ("0.2.0" ) is True
1575+
1576+ with changelog_path .open (encoding = "utf-8" ) as f :
1577+ content = f .read ()
1578+ with changelog_path .open ("w" , encoding = "utf-8" ) as f :
1579+ f .write (content .replace ("- **user**: new user" , "- **user**: new user\n \n MANUAL NOTE" ))
1580+ util .create_file_and_commit ("docs: add manual note to changelog" )
1581+
1582+ util .create_file_and_commit ("feat(admin): new admin" )
1583+ util .run_cli ("bump" , "--yes" )
1584+ assert git .tag_exist ("0.3.0" ) is True
1585+
1586+ with changelog_path .open (encoding = "utf-8" ) as f :
1587+ out = f .read ()
1588+ assert "0.3.0" in out
1589+ assert "0.2.0" in out
1590+ assert "MANUAL NOTE" not in out
0 commit comments