Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion commitizen/commands/bump.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,8 @@ def __call__(self) -> None: # noqa: C901
scheme=self.scheme,
)

is_initial = self.is_initial_tag(current_tag_version, is_yes)

# If user specified changelog_to_stdout, they probably want the
# changelog to be generated as well, this is the most intuitive solution
self.changelog = self.changelog or bool(self.changelog_to_stdout)
Expand All @@ -223,7 +225,6 @@ def __call__(self) -> None: # noqa: C901
) from exc
else:
if increment is None:
is_initial = self.is_initial_tag(current_tag_version, is_yes)
if is_initial:
commits = git.get_commits()
else:
Expand Down
23 changes: 23 additions & 0 deletions tests/commands/test_bump_command.py
Original file line number Diff line number Diff line change
Expand Up @@ -1007,6 +1007,29 @@ def test_bump_with_pre_bump_hooks(
)


def test_bump_with_hooks_and_increment(mocker: MockFixture, tmp_commitizen_project):
pre_bump_hook = "scripts/pre_bump_hook.sh"
post_bump_hook = "scripts/post_bump_hook.sh"

tmp_commitizen_cfg_file = tmp_commitizen_project.join("pyproject.toml")
tmp_commitizen_cfg_file.write(
f"{tmp_commitizen_cfg_file.read()}\n"
f'pre_bump_hooks = ["{pre_bump_hook}"]\n'
f'post_bump_hooks = ["{post_bump_hook}"]\n'
)

run_mock = mocker.Mock()
mocker.patch.object(hooks, "run", run_mock)

create_file_and_commit("test: some test")
testargs = ["cz", "bump", "--yes", "--increment", "MINOR"]
mocker.patch.object(sys, "argv", testargs)
cli.main()

tag_exists = git.tag_exist("0.2.0")
assert tag_exists is True


@pytest.mark.usefixtures("tmp_commitizen_project")
def test_bump_manual_version_disallows_prerelease_offset(mocker):
create_file_and_commit("feat: new file")
Expand Down