Skip to content

Commit d831c99

Browse files
ckagererLee-W
authored andcommitted
fix(bump): manual version bump if prerelease offset is configured
If you use the prerelase offset in the .cz.toml, as in the following example, no bump with a manual version number is possible. The error occurs when bumping with manual version number: cz bump 9.8.7 --prerelease-offset cannot be combined with MANUAL_VERSION ```toml [tool.commitizen] changelog_incremental = true tag_format = "v$version" update_changelog_on_bump = true version = "1.2.0b13" prerelease_offset = 1 ```
1 parent 295f975 commit d831c99

File tree

3 files changed

+1
-23
lines changed

3 files changed

+1
-23
lines changed

commitizen/commands/bump.py

-5
Original file line numberDiff line numberDiff line change
@@ -187,11 +187,6 @@ def __call__(self) -> None: # noqa: C901
187187
"--major-version-zero cannot be combined with MANUAL_VERSION"
188188
)
189189

190-
if prerelease_offset:
191-
raise NotAllowed(
192-
"--prerelease-offset cannot be combined with MANUAL_VERSION"
193-
)
194-
195190
if get_next:
196191
raise NotAllowed("--get-next cannot be combined with MANUAL_VERSION")
197192

docs/commands/bump.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -599,7 +599,7 @@ post_bump_hooks = [
599599

600600
### `prerelease_offset`
601601

602-
Offset with which to start counting prereleses.
602+
Offset with which to start counting prereleases.
603603

604604
Defaults to: `0`
605605

tests/commands/test_bump_command.py

-17
Original file line numberDiff line numberDiff line change
@@ -1041,23 +1041,6 @@ def test_bump_with_hooks_and_increment(mocker: MockFixture, tmp_commitizen_proje
10411041
assert tag_exists is True
10421042

10431043

1044-
@pytest.mark.usefixtures("tmp_commitizen_project")
1045-
def test_bump_manual_version_disallows_prerelease_offset(mocker):
1046-
create_file_and_commit("feat: new file")
1047-
1048-
manual_version = "0.2.0"
1049-
testargs = ["cz", "bump", "--yes", "--prerelease-offset", "42", manual_version]
1050-
mocker.patch.object(sys, "argv", testargs)
1051-
1052-
with pytest.raises(NotAllowed) as excinfo:
1053-
cli.main()
1054-
1055-
expected_error_message = (
1056-
"--prerelease-offset cannot be combined with MANUAL_VERSION"
1057-
)
1058-
assert expected_error_message in str(excinfo.value)
1059-
1060-
10611044
@pytest.mark.usefixtures("tmp_git_project")
10621045
def test_bump_use_version_provider(mocker: MockFixture):
10631046
mock = mocker.MagicMock(name="provider")

0 commit comments

Comments
 (0)