|
41 | 41 | "fix(user): username exception",
|
42 | 42 | "refactor: remove ini configuration support",
|
43 | 43 | "refactor(config): remove ini configuration support",
|
44 |
| - "perf: update to use multiproess", |
45 |
| - "perf(worker): update to use multiproess", |
| 44 | + "perf: update to use multiprocess", |
| 45 | + "perf(worker): update to use multiprocess", |
46 | 46 | ),
|
47 | 47 | )
|
48 | 48 | @pytest.mark.usefixtures("tmp_commitizen_project")
|
@@ -1688,3 +1688,55 @@ def test_bump_warn_but_dont_fail_on_invalid_tags(
|
1688 | 1688 |
|
1689 | 1689 | assert err.count("Invalid version tag: '0.4.3.deadbeaf'") == 1
|
1690 | 1690 | assert git.tag_exist("0.4.3")
|
| 1691 | + |
| 1692 | + |
| 1693 | +def test_is_initial_tag(mocker: MockFixture, tmp_commitizen_project): |
| 1694 | + """Test the is_initial_tag method behavior.""" |
| 1695 | + from commitizen import defaults |
| 1696 | + from commitizen.commands.bump import Bump |
| 1697 | + from commitizen.config import BaseConfig |
| 1698 | + |
| 1699 | + # Create a commit but no tags |
| 1700 | + create_file_and_commit("feat: initial commit") |
| 1701 | + |
| 1702 | + # Initialize Bump with minimal config |
| 1703 | + config = BaseConfig() |
| 1704 | + config.settings.update( |
| 1705 | + { |
| 1706 | + "name": defaults.DEFAULT_SETTINGS["name"], |
| 1707 | + "encoding": "utf-8", |
| 1708 | + "pre_bump_hooks": [], |
| 1709 | + "post_bump_hooks": [], |
| 1710 | + } |
| 1711 | + ) |
| 1712 | + |
| 1713 | + # Initialize with required arguments |
| 1714 | + arguments = { |
| 1715 | + "changelog": False, |
| 1716 | + "changelog_to_stdout": False, |
| 1717 | + "git_output_to_stderr": False, |
| 1718 | + "no_verify": False, |
| 1719 | + "check_consistency": False, |
| 1720 | + "retry": False, |
| 1721 | + "version_scheme": None, |
| 1722 | + "file_name": None, |
| 1723 | + "template": None, |
| 1724 | + "extras": None, |
| 1725 | + } |
| 1726 | + |
| 1727 | + bump_cmd = Bump(config, arguments) |
| 1728 | + |
| 1729 | + # Test case 1: No current tag, not yes mode |
| 1730 | + mocker.patch("questionary.confirm", return_value=mocker.Mock(ask=lambda: True)) |
| 1731 | + assert bump_cmd.is_initial_tag(None, is_yes=False) is True |
| 1732 | + |
| 1733 | + # Test case 2: No current tag, yes mode |
| 1734 | + assert bump_cmd.is_initial_tag(None, is_yes=True) is True |
| 1735 | + |
| 1736 | + # Test case 3: Has current tag |
| 1737 | + mock_tag = mocker.Mock() |
| 1738 | + assert bump_cmd.is_initial_tag(mock_tag, is_yes=False) is False |
| 1739 | + |
| 1740 | + # Test case 4: No current tag, user denies |
| 1741 | + mocker.patch("questionary.confirm", return_value=mocker.Mock(ask=lambda: False)) |
| 1742 | + assert bump_cmd.is_initial_tag(None, is_yes=False) is False |
0 commit comments