From a11f20317074773faac1ff4f250088505bc8c29d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Edgar=20Rami=CC=81rez=20Mondrago=CC=81n?= Date: Sat, 2 Jul 2022 13:41:07 -0500 Subject: [PATCH] feat(bump): make increment option case insensitive Use str.upper to pre-process the input of --increment --- commitizen/cli.py | 1 + tests/commands/test_bump_command.py | 21 +++++++++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/commitizen/cli.py b/commitizen/cli.py index 90abc55453..0f2d52efc9 100644 --- a/commitizen/cli.py +++ b/commitizen/cli.py @@ -145,6 +145,7 @@ "name": ["--increment"], "help": "manually specify the desired increment", "choices": ["MAJOR", "MINOR", "PATCH"], + "type": str.upper, }, { "name": ["--check-consistency", "-cc"], diff --git a/tests/commands/test_bump_command.py b/tests/commands/test_bump_command.py index 1d1df88979..da15174c5d 100644 --- a/tests/commands/test_bump_command.py +++ b/tests/commands/test_bump_command.py @@ -109,6 +109,27 @@ def test_bump_major_increment(commit_msg, mocker): assert tag_exists is True +@pytest.mark.usefixtures("tmp_commitizen_project") +@pytest.mark.parametrize( + "commit_msg,increment,expected_tag", + [ + ("feat: new file", "PATCH", "0.1.1"), + ("fix: username exception", "major", "1.0.0"), + ("refactor: remove ini configuration support", "patch", "0.1.1"), + ("BREAKING CHANGE: age is no longer supported", "minor", "0.2.0"), + ], +) +def test_bump_command_increment_option(commit_msg, increment, expected_tag, mocker): + create_file_and_commit(commit_msg) + + testargs = ["cz", "bump", "--increment", increment, "--yes"] + mocker.patch.object(sys, "argv", testargs) + cli.main() + + tag_exists = git.tag_exist(expected_tag) + assert tag_exists is True + + @pytest.mark.usefixtures("tmp_commitizen_project") def test_bump_command_prelease(mocker): # PRERELEASE