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