From d82dd5adf2e6382cbcb06b8511cfed5ec6d6ada0 Mon Sep 17 00:00:00 2001 From: "andre.liang" Date: Sun, 1 Feb 2026 08:01:14 +0800 Subject: [PATCH 1/5] feat: add ignore_bump_sha_list and ignore_bump_author_list to find_increment --- commitizen/bump.py | 18 +++++++++++++++- commitizen/commands/bump.py | 13 +++++++++-- tests/test_bump_find_increment.py | 36 +++++++++++++++++++++++++++++++ 3 files changed, 64 insertions(+), 3 deletions(-) diff --git a/commitizen/bump.py b/commitizen/bump.py index cb572d3612..7ae3ec4fad 100644 --- a/commitizen/bump.py +++ b/commitizen/bump.py @@ -23,7 +23,11 @@ def find_increment( - commits: list[GitCommit], regex: str, increments_map: dict | OrderedDict + commits: list[GitCommit], + regex: str, + increments_map: dict | OrderedDict, + ignore_bump_sha_list: list[str] | None = None, + ignore_bump_author_list: list[str] | None = None, ) -> Increment | None: if isinstance(increments_map, dict): increments_map = OrderedDict(increments_map) @@ -34,6 +38,18 @@ def find_increment( increment: str | None = None for commit in commits: + if ignore_bump_sha_list and commit.rev in ignore_bump_sha_list: + logger.debug( + f"Skipping commit {commit.rev} as it's in ignore_bump_sha_list" + ) + continue + + if ignore_bump_author_list and commit.author in ignore_bump_author_list: + logger.debug( + f"Skipping commit {commit.rev} as its author '{commit.author}' is in ignore_bump_author_list" + ) + continue + for message in commit.message.split("\n"): result = select_pattern.search(message) diff --git a/commitizen/commands/bump.py b/commitizen/commands/bump.py index 6084c8c151..419beaa4ee 100644 --- a/commitizen/commands/bump.py +++ b/commitizen/commands/bump.py @@ -158,7 +158,11 @@ def _find_increment(self, commits: list[git.GitCommit]) -> Increment | None: raise NoPatternMapError( f"'{self.config.settings['name']}' rule does not support bump" ) - return bump.find_increment(commits, regex=bump_pattern, increments_map=bump_map) + return bump.find_increment( + commits, + regex=bump_pattern, + increments_map=bump_map, + ) def _validate_arguments(self, current_version: VersionProtocol) -> None: errors: list[str] = [] @@ -363,6 +367,9 @@ def __call__(self) -> None: new_tag_version=new_tag_version, message=message, increment=increment, + changelog_file_name=( + changelog_cmd.file_name if self.changelog_flag else None + ), changelog_file_name=changelog_file_name, ) @@ -426,7 +433,9 @@ def __call__(self) -> None: current_tag_version=new_tag_version, message=message, increment=increment, - changelog_file_name=changelog_file_name, + changelog_file_name=( + changelog_cmd.file_name if self.changelog_flag else None + ), ) # TODO: For v3 output this only as diagnostic and remove this if diff --git a/tests/test_bump_find_increment.py b/tests/test_bump_find_increment.py index 8209278ed5..138234c47d 100644 --- a/tests/test_bump_find_increment.py +++ b/tests/test_bump_find_increment.py @@ -108,6 +108,42 @@ def test_find_increment(messages, expected_type): assert increment_type == expected_type +def test_find_increment_with_ignored_sha(): + messages = [ + "docs(README): motivation", + "BREAKING CHANGE: your upstream dependency have some breaking changes", + ] + commits = [ + GitCommit(rev="test1", title=messages[0]), + GitCommit(rev="test2", title=messages[1]), + ] + increment_type = bump.find_increment( + commits, + regex=ConventionalCommitsCz.bump_pattern, + increments_map=ConventionalCommitsCz.bump_map, + ignore_bump_sha_list=["test2"], + ) + assert increment_type is None + + +def test_find_increment_with_ignored_author(): + messages = [ + "BREAKING CHANGE: your upstream dependency have some breaking changes", + "docs(README): motivation", + ] + commits = [ + GitCommit(rev="test1", title=messages[0], author="alice"), + GitCommit(rev="test2", title=messages[1], author="bob"), + ] + increment_type = bump.find_increment( + commits, + regex=ConventionalCommitsCz.bump_pattern, + increments_map=ConventionalCommitsCz.bump_map, + ignore_bump_author_list=["alice"], + ) + assert increment_type is None + + @pytest.mark.parametrize( ("messages", "expected_type"), [ From 0488175d5d0ffa91f8a97161a6b7bead7b5ac513 Mon Sep 17 00:00:00 2001 From: "andre.liang" Date: Sun, 1 Feb 2026 08:14:03 +0800 Subject: [PATCH 2/5] feat(config): add ignore_bump_sha_list and ignore_bump_author_list to Settings --- commitizen/commands/bump.py | 6 ++++++ commitizen/defaults.py | 2 ++ 2 files changed, 8 insertions(+) diff --git a/commitizen/commands/bump.py b/commitizen/commands/bump.py index 419beaa4ee..4d93f4a560 100644 --- a/commitizen/commands/bump.py +++ b/commitizen/commands/bump.py @@ -104,6 +104,10 @@ def __init__(self, config: BaseConfig, arguments: BumpArgs) -> None: self.retry = arguments["retry"] self.pre_bump_hooks = self.config.settings["pre_bump_hooks"] self.post_bump_hooks = self.config.settings["post_bump_hooks"] + self.ignore_bump_sha_list = self.config.settings.get("ignore_bump_sha_list") + self.ignore_bump_author_list = self.config.settings.get( + "ignore_bump_author_list" + ) deprecated_version_type = arguments.get("version_type") if deprecated_version_type: warnings.warn( @@ -162,6 +166,8 @@ def _find_increment(self, commits: list[git.GitCommit]) -> Increment | None: commits, regex=bump_pattern, increments_map=bump_map, + ignore_bump_sha_list=self.ignore_bump_sha_list, + ignore_bump_author_list=self.ignore_bump_author_list, ) def _validate_arguments(self, current_version: VersionProtocol) -> None: diff --git a/commitizen/defaults.py b/commitizen/defaults.py index 4865ccc188..c36022c942 100644 --- a/commitizen/defaults.py +++ b/commitizen/defaults.py @@ -65,6 +65,8 @@ class Settings(TypedDict, total=False): version_type: str | None version: str | None breaking_change_exclamation_in_title: bool + ignore_bump_sha_list: list[str] | None + ignore_bump_author_list: list[str] | None CONFIG_FILES: tuple[str, ...] = ( From b753dd5faf6ee3cd519510321638e1bb5d2861f2 Mon Sep 17 00:00:00 2001 From: "andre.liang" Date: Sat, 7 Feb 2026 21:16:16 +0800 Subject: [PATCH 3/5] fix: fix errors when merging --- commitizen/commands/bump.py | 1 - 1 file changed, 1 deletion(-) diff --git a/commitizen/commands/bump.py b/commitizen/commands/bump.py index 4d93f4a560..b028a5e2fd 100644 --- a/commitizen/commands/bump.py +++ b/commitizen/commands/bump.py @@ -376,7 +376,6 @@ def __call__(self) -> None: changelog_file_name=( changelog_cmd.file_name if self.changelog_flag else None ), - changelog_file_name=changelog_file_name, ) if self.arguments.get("files_only"): From 49c7e2d6c42791dc424fe25f895a509d152ae020 Mon Sep 17 00:00:00 2001 From: "andre.liang" Date: Sat, 7 Feb 2026 21:52:03 +0800 Subject: [PATCH 4/5] fix: align naming convension --- commitizen/bump.py | 6 +++--- commitizen/commands/bump.py | 4 ++-- commitizen/defaults.py | 2 +- tests/test_bump_find_increment.py | 8 ++++---- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/commitizen/bump.py b/commitizen/bump.py index 7ae3ec4fad..54b54b083b 100644 --- a/commitizen/bump.py +++ b/commitizen/bump.py @@ -26,7 +26,7 @@ def find_increment( commits: list[GitCommit], regex: str, increments_map: dict | OrderedDict, - ignore_bump_sha_list: list[str] | None = None, + ignore_bump_rev_list: list[str] | None = None, ignore_bump_author_list: list[str] | None = None, ) -> Increment | None: if isinstance(increments_map, dict): @@ -38,9 +38,9 @@ def find_increment( increment: str | None = None for commit in commits: - if ignore_bump_sha_list and commit.rev in ignore_bump_sha_list: + if ignore_bump_rev_list and commit.rev in ignore_bump_rev_list: logger.debug( - f"Skipping commit {commit.rev} as it's in ignore_bump_sha_list" + f"Skipping commit {commit.rev} as it's in ignore_bump_rev_list" ) continue diff --git a/commitizen/commands/bump.py b/commitizen/commands/bump.py index b028a5e2fd..c35b1be4aa 100644 --- a/commitizen/commands/bump.py +++ b/commitizen/commands/bump.py @@ -104,7 +104,7 @@ def __init__(self, config: BaseConfig, arguments: BumpArgs) -> None: self.retry = arguments["retry"] self.pre_bump_hooks = self.config.settings["pre_bump_hooks"] self.post_bump_hooks = self.config.settings["post_bump_hooks"] - self.ignore_bump_sha_list = self.config.settings.get("ignore_bump_sha_list") + self.ignore_bump_rev_list = self.config.settings.get("ignore_bump_rev_list") self.ignore_bump_author_list = self.config.settings.get( "ignore_bump_author_list" ) @@ -166,7 +166,7 @@ def _find_increment(self, commits: list[git.GitCommit]) -> Increment | None: commits, regex=bump_pattern, increments_map=bump_map, - ignore_bump_sha_list=self.ignore_bump_sha_list, + ignore_bump_rev_list=self.ignore_bump_rev_list, ignore_bump_author_list=self.ignore_bump_author_list, ) diff --git a/commitizen/defaults.py b/commitizen/defaults.py index c36022c942..703fbd9ff7 100644 --- a/commitizen/defaults.py +++ b/commitizen/defaults.py @@ -65,7 +65,7 @@ class Settings(TypedDict, total=False): version_type: str | None version: str | None breaking_change_exclamation_in_title: bool - ignore_bump_sha_list: list[str] | None + ignore_bump_rev_list: list[str] | None ignore_bump_author_list: list[str] | None diff --git a/tests/test_bump_find_increment.py b/tests/test_bump_find_increment.py index 138234c47d..811fb433a7 100644 --- a/tests/test_bump_find_increment.py +++ b/tests/test_bump_find_increment.py @@ -108,10 +108,10 @@ def test_find_increment(messages, expected_type): assert increment_type == expected_type -def test_find_increment_with_ignored_sha(): +def test_find_increment_with_ignored_rev(): messages = [ "docs(README): motivation", - "BREAKING CHANGE: your upstream dependency have some breaking changes", + "feat: this should not be bumped because of the ignore_bump_rev_list", ] commits = [ GitCommit(rev="test1", title=messages[0]), @@ -121,14 +121,14 @@ def test_find_increment_with_ignored_sha(): commits, regex=ConventionalCommitsCz.bump_pattern, increments_map=ConventionalCommitsCz.bump_map, - ignore_bump_sha_list=["test2"], + ignore_bump_rev_list=["test2"], ) assert increment_type is None def test_find_increment_with_ignored_author(): messages = [ - "BREAKING CHANGE: your upstream dependency have some breaking changes", + "feat: this should not be bumped because of the ignore_bump_author_list", "docs(README): motivation", ] commits = [ From 486d9a068efdba279afb70f58877b9942cb5cfb4 Mon Sep 17 00:00:00 2001 From: "andre.liang" Date: Sat, 7 Feb 2026 22:02:03 +0800 Subject: [PATCH 5/5] chore: update document --- docs/config/bump.md | 54 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) diff --git a/docs/config/bump.md b/docs/config/bump.md index 10ca5bcf8d..403e232a1e 100644 --- a/docs/config/bump.md +++ b/docs/config/bump.md @@ -215,3 +215,57 @@ version_files = [ ## `version_scheme` See [`--version-scheme`](../commands/bump.md#-version-scheme). + +Here’s a clearer, more consistent rewrite with tightened wording, corrected descriptions, and parallel structure between the two options. + +## `ignore_bump_rev_list` + +- Type: `list` +- Default: `[]` + +A list of git commit revisions (SHAs) that should be excluded from version bump calculation. + +For example, given the following commit: + +```text +commit e302cb4f2c626099b4a9c8cf881b0bb5906b7356 +Author: example_user +Date: Sat Feb 1 21:00:00 2026 +0800 + + feat: add a new test file, this should not be bumped +``` + +Configure `pyproject.toml` as follows: + +```toml title="pyproject.toml" +[tool.commitizen] +ignore_bump_rev_list = ["e302cb4f2c626099b4a9c8cf881b0bb5906b7356"] +``` + +As a result, this commit will be ignored when determining whether a version bump is required. + +## `ignore_bump_author_list` + +- Type: `list` +- Default: `[]` + +A list of commit authors whose commits should be excluded from version bump calculation. + +For example, given the following commit: + +```text +commit e302cb4f2c626099b4a9c8cf881b0bb5906b7356 +Author: example_user +Date: Sat Feb 1 21:00:00 2026 +0800 + + feat: add a new test file, this should not be bumped +``` + +Configure `pyproject.toml` as follows: + +```toml title="pyproject.toml" +[tool.commitizen] +ignore_bump_author_list = ["example_user"] +``` + +As a result, any commit authored by `example_user` will be ignored when determining whether a version bump is required.