Skip to content

refactor(bump): use VersionIncrement ordering for bump detection - #2097

Open
bearomorphism wants to merge 2 commits into
masterfrom
fm/commitizen-bumprule-pr
Open

bearomorphism wants to merge 2 commits into
masterfrom
fm/commitizen-bumprule-pr

Conversation

@bearomorphism

@bearomorphism bearomorphism commented Sep 30, 2026 •

Copy link
Copy Markdown
Collaborator

Description

This PR extracts the find_increment removal from the larger BumpRule redesign by replacing it with comparable VersionIncrement helpers and shared max-based increment selection.

It keeps the current bump_pattern / bump_map behavior intact, including:

  • filtered commits before bump/version calculation
  • major_version_zero
  • legacy invalid custom-map failures
  • existing no-increment semantics

Checklist

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

  • Yes (Pi / no-mistakes)

Generated-by: Pi / no-mistakes following http://commitizen-tools.github.io/commitizen/contributing/pull_request/#ai-assisted-contributions

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)

Expected Behavior

cz bump and cz version --project --next USE_GIT_COMMITS should keep their existing bump-selection behavior after commitizen.bump.find_increment is removed, while internal increment selection now uses comparable VersionIncrement values.

A documented None / null bump_map value should also match the public typed plugin/config contract, while the string "NONE" remains invalid.

Steps to Test This Pull Request

  1. Run the targeted regression suite for bump/version behavior.
  2. Exercise cz bump and cz version --project --next USE_GIT_COMMITS in isolated repos covering invalid custom bump maps, multiline MAJOR handling, filtered commits, major_version_zero, and actual None bump-map values.
  3. Confirm the current PR head passes GitHub checks.

Additional Context

  • This PR was rewritten to a single commit after no-mistakes introduced intermediate fix commits during validation, then received one follow-up commit for the typed None bump-map contract.
  • Local validation for the follow-up head passed: ruff check, ruff format --check, mypy, and targeted bump/version pytest coverage (223 passed).
  • GitHub checks for the current head should be treated as the source of truth after the latest push.

@github-actions

github-actions Bot commented Sep 30, 2026 •

Copy link
Copy Markdown
Contributor

🔍 Commitizen bump preview

Merging this PR will produce the following bump:

bump: version 4.19.0 → 4.19.1
tag to create: v4.19.1
increment detected: PATCH

## v4.19.1 (2026-10-01)

### Fix

- **types**: allow documented None bump_map values

### Refactor

- **bump**: replace find_increment with VersionIncrement max

@codecov

codecov Bot commented Sep 30, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.28%. Comparing base (3f5ccc8) to head (13cd81d).
⚠️ Report is 3 commits behind head on master.
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2097      +/-   ##
==========================================
+ Coverage   98.27%   98.28%   +0.01%     
==========================================
  Files          61       61              
  Lines        2836     2861      +25     
==========================================
+ Hits         2787     2812      +25     
  Misses         49       49              

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

@bearomorphism
bearomorphism force-pushed the fm/commitizen-bumprule-pr branch from 3a7ff2c to 6585f2c Compare October 1, 2026 01:52
@bearomorphism bearomorphism changed the title fix(bump): use VersionIncrement ordering for bump detection refactor(bump): use VersionIncrement ordering for bump detection Oct 1, 2026
@bearomorphism

Copy link
Copy Markdown
Collaborator Author

Previous PR: #1518

This is smaller and the goal is to remove bump.find_increment first

@bearomorphism
bearomorphism requested review from Lee-W and woile and a balanced review from Copilot October 1, 2026 02:21

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟡 Changes recommended

The documented None mapping conflicts with the public bump-map type annotations.

Review effort: Balanced
Findings: 1 Medium severity

Open (1)
What changed in this PR

Centralizes bump detection around ordered VersionIncrement values while preserving existing CLI behavior.

Changes:

  • Replaces find_increment with shared increment helpers.
  • Updates bump/version commands and regression coverage.
  • Documents no-bump custom mappings.
File Description
commitizen/​version_increment.py Adds ordered increment extraction helpers.
commitizen/​bump.py Removes legacy increment detection.
commitizen/​commands/​bump.py Uses shared increment selection.
commitizen/​commands/​version.py Reuses selection for commit-derived versions.
tests/​test_version_increment.py Adds helper and compatibility tests.
tests/​test_bump_find_increment.py Removes obsolete tests.
tests/​commands/​test_bump_command.py Tests invalid custom mappings.
docs/​customization/​python_class.md Documents None mappings.
docs/​customization/​config_file.md Documents JSON/YAML null mappings.

💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

| -------------- | ------ | ------- | ----------------------------------------------------------------------------------------------------- |
| `bump_pattern` | `str` | `None` | Regex to extract information from commit (subject and body) |
| `bump_map` | `dict` | `None` | Dictionary mapping the extracted information to a `SemVer` increment type (`MAJOR`, `MINOR`, `PATCH`) |
| `bump_map` | `dict` | `None` | Dictionary mapping the extracted information to a `SemVer` increment type (`MAJOR`, `MINOR`, `PATCH`). Use `None` when a matched rule should not bump the version. |

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants