Skip to content

refactor(bump): extract GitReleasePublisher from Bump - #2133

Closed
MrBubune wants to merge 5 commits into
commitizen-tools:masterfrom
MrBubune:refactor/bump-git-publisher
Closed

MrBubune wants to merge 5 commits into
commitizen-tools:masterfrom
MrBubune:refactor/bump-git-publisher

Conversation

@MrBubune

Copy link
Copy Markdown

Description

Part of #2129. Depends on #2130.

Bump decided what to release and also wrote the release to git. Move the git commit, the commit retry and the tag steps into a new GitReleasePublisher class in commands/bump.py. Its fields are no_verify, retry and git_output_to_stderr. Bump now calls self.git_publisher.commit(...) and .tag(...).

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 commit, retry, output and tag behavior as before.

Steps to Test This Pull Request

  1. uv run poe all
  2. New tests in tests/test_git_release_publisher.py cover these cases:
    • retry once after the changelog was updated
    • no retry without a changelog update
    • --no-verify is passed to git
    • a failed tag raises BumpTagFailedError
  3. In a scratch repo, run cz bump --changelog --yes and check the commit and tag.

Additional Context

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.
Bump decided what to release and also wrote it to git. Move the
commit, retry and tag steps and their three settings into
GitReleasePublisher. Add tests for retry and for commit and tag errors.
@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 (06e8ef1).
⚠️ Report is 1 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2133      +/-   ##
==========================================
+ Coverage   98.29%   98.30%   +0.01%     
==========================================
  Files          61       61              
  Lines        2874     2891      +17     
==========================================
+ Hits         2825     2842      +17     
  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