Skip to content

refactor(bump): split Bump.__call__ into smaller steps - #2130

Closed
MrBubune wants to merge 4 commits into
commitizen-tools:masterfrom
MrBubune:refactor/bump-call
Closed

MrBubune wants to merge 4 commits into
commitizen-tools:masterfrom
MrBubune:refactor/bump-call

Conversation

@MrBubune

Copy link
Copy Markdown

Description

Behavior-preserving refactor of Bump.__call__ (172 lines, cyclomatic complexity 27). Part of #2129.

  • Rename the reused variable c to commit_result and tag_result.
  • Move the tag sign/annotate any() expressions into should_sign_tag and should_annotate_tag.
  • Extract the duplicate "no increment and same tag" check into _is_not_eligible_for_bump, and the commit retry check into _should_retry_commit.
  • Extract the changelog step into _update_changelog.

One commit per change, so each step can be reviewed alone.

Checklist

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

  • Yes (please specify the tool below)

Generated-by: Claude Code following the guidelines. AI suggested the changes; I wrote and reviewed the code by hand.

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

Expected Behavior

No change. Same CLI output, files, commits, tags and exit codes as before.

Steps to Test This Pull Request

  1. uv run poe all: 1351 passed, 3 skipped, 2 xfailed; coverage unchanged.
  2. In a scratch git repo with a pyproject.toml commitizen config, run cz bump --dry-run and cz bump --changelog --yes, and compare output and tag with the master branch.

Additional Context

No new tests: the existing tests in tests/commands/test_bump_command.py cover all changed paths. Pure refactor, so no docs change.

The variable c held the git commit result and then the git tag result.
Use commit_result and tag_result so each name tells what it holds.
Move the two inline any() expressions out of the git.tag() call into
should_sign_tag and should_annotate_tag.
The "no increment and same tag" condition was written twice in
__call__. Move it to _is_not_eligible_for_bump. Move the commit retry
condition to _should_retry_commit.
Move the changelog block into _update_changelog to make __call__
shorter. No change in behavior.
@codecov

codecov Bot commented Nov 25, 2026 •

Copy link
Copy Markdown

Codecov Report

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

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #2130   +/-   ##
=======================================
  Coverage   98.29%   98.30%           
=======================================
  Files          61       61           
  Lines        2874     2884   +10     
=======================================
+ Hits         2825     2835   +10     
  Misses         49       49           

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

@woile

woile commented Nov 26, 2026

Copy link
Copy Markdown
Member

Hi thanks for this but it doesn't add any value

@woile woile closed this Nov 26, 2026
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