Repository navigation
feat(bump): add --no-commit to tag the current HEAD without a bump commit - #2123
Open
VamikaSinghal wants to merge 1 commit into
Open
VamikaSinghal wants to merge 1 commit into
VamikaSinghal wants to merge 1 commit into
Conversation
…mmit `cz bump --no-commit` updates the version files and the changelog, runs the hooks and creates the tag as usual, but does not stage or commit anything: the tag points to the current HEAD and the updated files stay in the working tree. This is the explicit opt-out asked for in commitizen-tools#753, for projects that keep the version in Git tags only (for example `version_provider = "scm"`) and do not want a release commit, such as a CI job tagging the commit that triggered it. Closes commitizen-tools#753 Assisted By: AI Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #2123 +/- ##
=======================================
Coverage 98.29% 98.29%
=======================================
Files 61 61
Lines 2866 2875 +9
=======================================
+ Hits 2817 2826 +9
Misses 49 49 ☔ View full report in Codecov by Harness. |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Adds
cz bump --no-commit, the opt-out asked for in #753: the bump still updates theversion_filesand the changelog, runs thepre_bump_hooks/post_bump_hooksand creates the tag, but it does not stage or commit anything. The tag points to the currentHEADand the updated files stay in the working tree.Why: projects that keep the version in Git tags only (
version_provider = "scm") do not want a release commit, e.g. a CI job that tags the commit which triggered it. Todaycz bumpfails for them with2nd git.commit error: "nothing to commit, working tree clean"(exit code 6), and the SCM tutorial documents a manualcz version+cz changelog+git tagsequence instead. #1969 skips the commit automatically when there is nothing to commit; this PR adds the explicit flag from the issue, which also covers the case where files were updated (changelog,version_files) but the user does not want them committed. The two changes touch the same block and rebase trivially on top of each other.Changes:
commitizen/commands/bump.py: newno_commitargument; the existing add/commit/retry block moved unchanged intoBump._commit(), andBump._report_skipped_commit()prints one line (to stderr when--changelog-to-stdoutis used, so stdout stays the changelog). The tag step is unchanged.commitizen/cli.py: the--no-commitoption (CLI only, like--allow-no-commit).docs/commands/bump.md: a--no-commitsection, with a note on how it differs from--allow-no-commitand--version-files-only;docs/tutorials/release-scm.md: fixes thescptypo in the intro and adds a tip pointing to the flag before the manualgit tagrecipe.tests/commands/test_bump_command.py: two tests (tag on the previousHEAD,git.commitnever called, config file left modified and unstaged;--changelog-to-stdoutkeeps stdout clean and leavesCHANGELOG.mduntracked). Thecz bump --helpregression snapshots for Python 3.10–3.14 were regenerated with--force-regenunder each interpreter.Closes #753
Checklist
Was generative AI tooling used to co-author this PR?
Generated-by: Claude Code following the guidelines
Code Changes
uv run poe alllocally to ensure this change passes linter check and testsDocumentation Changes
uv run poe doclocally to ensure the documentation pages renders correctlyExpected Behavior
cz bump --no-commitbehaves likecz bumpexcept that no commit is created: same version calculation, file updates, hooks and tag; the tag is placed on the currentHEAD. Without the flag nothing changes.Steps to Test This Pull Request
The 4
*_signed*bump tests error on my machine becausegpgis not installed; they are unrelated and error onmastertoo.Manual run in a throwaway repo with
version_provider = "scm", wherecz bumpfails today:With the version in
pyproject.tomlandupdate_changelog_on_bump = true, the files are updated but left uncommitted:cz bump --yes --no-commit --changelog-to-stdout > body.mdwrites only the changelog tobody.md; the--no-commitline goes to stderr.Additional Context
Related: #1969 (skip the commit automatically when there are no file changes), #753 discussion where woile and Lee-W preferred "just create a tag" for the SCM case. The option is CLI-only for now; a
no_commitsetting could be added later if wanted.🤖 Generated with Claude Code