@@ -1540,3 +1540,46 @@ def test_changelog_merge_preserves_header(
15401540 out = changelog_path .read_text ()
15411541
15421542 file_regression .check (out , extension = ".md" )
1543+
1544+
1545+ @pytest .mark .freeze_time ("2025-01-01" )
1546+ def test_bump_allow_no_commit_issue (
1547+ tmp_commitizen_project_initial ,
1548+ util : UtilFixture ,
1549+ ) -> None :
1550+ """Issue #1866: bump command called changelog command with allow_no_commit=True, but changelog command raised NoCommitsFoundError"""
1551+ tmp_commitizen_project = tmp_commitizen_project_initial (version = "1.0.0" )
1552+ with (tmp_commitizen_project / "pyproject.toml" ).open ("w" ) as f :
1553+ f .write (
1554+ dedent (
1555+ r"""
1556+ [project]
1557+ name = "abc"
1558+ version = "4.14.0"
1559+
1560+ [tool.commitizen]
1561+ name = "cz_customize"
1562+ tag_format = "$version"
1563+ version_scheme = "semver2"
1564+ version_provider = "pep621"
1565+ update_changelog_on_bump = true
1566+
1567+ [tool.commitizen.customize]
1568+ bump_pattern = '^(feat|fix|ci|build|perf|refactor|chore|remove|style|test)'
1569+ bump_map = {feat = "MINOR", fix = "PATCH", ci = "PATCH", build = "PATCH", perf = "PATCH", refactor = "PATCH", chore = "PATCH", remove = "PATCH", style = "PATCH", test = "PATCH" }
1570+ schema_pattern = "(build|bump|chore|ci|dev|docs|feat|fix|perf|refactor|remove|style|test):(\\s.*)"
1571+ commit_parser = "^(?P<change_type>build|bump|chore|ci|dev|docs|feat|fix|perf|refactor|remove|style|test):\\s(?P<message>.*)?"
1572+ # By excluding 'bump', 'ci', 'dev', and 'docs' from
1573+ # 'change_type_map', 'change_type_order' and 'changelog_pattern'
1574+ # we omit the corresponding commit comments from the CHANGELOG.
1575+ # The order of types in the CHANGELOG is dictated by the type_order
1576+ change_type_map = {"feat" = "New Features", "fix" = "Bug Fixes", "perf" = "Performance Improvements", "refactor" = "Refactoring", "chore" = "General Improvements", "remove" = "Removed", "style" = "Stylistic Changes", "test" = "Testing", "build" = "Build"}
1577+ change_type_order = ["BREAKING CHANGE", "New Features", "Bug Fixes", "Performance Improvements", "Refactoring", "General Improvements", "Removed", "Stylistic Changes", "Testing", "Build"]
1578+ changelog_pattern = "^(build|chore|feat|fix|perf|refactor|remove|style|test)"
1579+ """
1580+ )
1581+ )
1582+ util .run_cli ("bump" , "--yes" , "--allow-no-commit" , "--prerelease" , "beta" )
1583+ util .run_cli (
1584+ "bump" , "--allow-no-commit" , "--prerelease" , "rc"
1585+ ) # Failed because the bump command called changelog command
0 commit comments