From 8cf6ded5a88f2a683bd25ca6d981b89da434595e Mon Sep 17 00:00:00 2001 From: Jannis Mattheis Date: Mon, 26 Jun 2023 16:18:16 +0200 Subject: [PATCH] fix(bump): version bumping The old implementation wrongly set the `increment` variable to `None` if `increment = "PATCH"` and `new_increment = None`. --- commitizen/bump.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/commitizen/bump.py b/commitizen/bump.py index 979d06603..7b80fc1e5 100644 --- a/commitizen/bump.py +++ b/commitizen/bump.py @@ -10,6 +10,8 @@ from commitizen.git import GitCommit, smart_open from commitizen.version_schemes import DEFAULT_SCHEME, Version, VersionScheme +VERSION_TYPES = [None, PATCH, MINOR, MAJOR] + def find_increment( commits: list[GitCommit], regex: str, increments_map: dict | OrderedDict @@ -34,12 +36,11 @@ def find_increment( new_increment = increments_map[match_pattern] break + if VERSION_TYPES.index(increment) < VERSION_TYPES.index(new_increment): + increment = new_increment + if increment == MAJOR: break - elif increment == MINOR and new_increment == MAJOR: - increment = new_increment - elif increment == PATCH or increment is None: - increment = new_increment return increment