Sitelet https://github.com/commitizen-tools/commitizen/pull/2078
Skip to content

feat(bump): add commit filter pattern - #2078

Open
schlotter wants to merge 1 commit into
commitizen-tools:masterfrom
ZEISS:feature/bump-support-filtering-commits
Open

feat(bump): add commit filter pattern#2078
schlotter wants to merge 1 commit into
commitizen-tools:masterfrom
ZEISS:feature/bump-support-filtering-commits

Conversation

@schlotter

Copy link
Copy Markdown
Contributor

Description

This change adds support for filtering commits before Commitizen evaluates them for version bumps by introducing a new bump_commit_filter_pattern setting.

The new setting defaults to .*, so existing projects keep the current behavior. When configured, cz bump and cz version --next USE_GIT_COMMITS only consider commits whose full message matches the filter pattern before applying the existing bump rules. This is particularly useful for monorepos where only a subset of commits should affect a package's version.

The pull request also updates the related documentation and adds regression tests covering the new filtering behavior and fallback paths.

Checklist

Was generative AI tooling used to co-author this PR?

  • Yes (GitHub Copilot CLI)

Generated-by: GitHub Copilot CLI following the guidelines

Code Changes

  • Add test cases to all the changes you introduce
  • Run uv run poe all locally to ensure this change passes linter check and tests
  • Manually test the changes:
    • Verify the feature/bug fix works as expected in real-world scenarios
    • Test edge cases and error conditions
    • Ensure backward compatibility is maintained
    • Document any manual testing steps performed
  • Update the documentation for the changes

Documentation Changes

  • Run uv run poe doc locally to ensure the documentation pages renders correctly
  • Check and fix any broken links (internal or external) — There were no broken links.

Expected Behavior

Projects can opt into filtering commits used for bump calculation without changing the default behavior for existing users. With bump_commit_filter_pattern configured, unrelated commits are ignored before bump_pattern is applied, so cz bump and cz version --next USE_GIT_COMMITS derive the next version only from relevant commits.

Steps to Test This Pull Request

  1. Configure Commitizen with bump_commit_filter_pattern for a subset of commit messages, for example ^fix\(library-b\):.
  2. Create a baseline tag and add commits that include both matching and non-matching messages.
  3. Run cz bump --dry-run or cz bump --get-next and confirm that only matching commits affect the calculated increment.
  4. Run cz version --project --next USE_GIT_COMMITS and confirm it reports the version derived from the filtered commit set.
  5. Remove the setting or leave it at the default and confirm the previous behavior is preserved.

Additional Context

Related discussion: #2075

Manual testing and validation performed during development included targeted pytest coverage for:

  • commit filtering in bump calculation
  • USE_GIT_COMMITS next-version calculation with filters
  • fallback behavior when no explicit filter is configured
  • configuration and documentation updates for the new setting

@codecov

codecov Bot commented Aug 25, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.31%. Comparing base (d914b4d) to head (1e56d63).
⚠️ Report is 1 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2078      +/-   ##
==========================================
+ Coverage   98.19%   98.31%   +0.11%     
==========================================
  Files          61       61              
  Lines        2829     2851      +22     
==========================================
+ Hits         2778     2803      +25     
+ Misses         51       48       -3     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

commitizen-tools#2075
@schlotter
schlotter force-pushed the feature/bump-support-filtering-commits branch from 110defc to 1e56d63 Compare August 25, 2026 14:13
@schlotter
schlotter marked this pull request as ready for review August 25, 2026 14:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant