From 210ff5174b83b24f46ae7c433e1920edc5e6e7dc Mon Sep 17 00:00:00 2001 From: Yu-Ting Hsiung Date: Fri, 6 Jun 2025 01:33:04 +0800 Subject: [PATCH] refactor(bump): simplify nested if --- commitizen/commands/bump.py | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/commitizen/commands/bump.py b/commitizen/commands/bump.py index a4024eee3..f534c3f5d 100644 --- a/commitizen/commands/bump.py +++ b/commitizen/commands/bump.py @@ -206,17 +206,13 @@ def __call__(self) -> None: if get_next: raise NotAllowed("--get-next cannot be combined with MANUAL_VERSION") - if self.bump_settings["major_version_zero"]: - if not current_version.release[0] == 0: - raise NotAllowed( - f"--major-version-zero is meaningless for current version {current_version}" - ) + if self.bump_settings["major_version_zero"] and current_version.release[0]: + raise NotAllowed( + f"--major-version-zero is meaningless for current version {current_version}" + ) - if build_metadata: - if is_local_version: - raise NotAllowed( - "--local-version cannot be combined with --build-metadata" - ) + if build_metadata and is_local_version: + raise NotAllowed("--local-version cannot be combined with --build-metadata") if get_next: # if trying to use --get-next, we should not allow --changelog or --changelog-to-stdout