René's URL Explorer Experiment


Title: fix(bump): skip commit step when there are no files to commit by bearomorphism · Pull Request #1969 · commitizen-tools/commitizen · GitHub

Open Graph Title: fix(bump): skip commit step when there are no files to commit by bearomorphism · Pull Request #1969 · commitizen-tools/commitizen

X Title: fix(bump): skip commit step when there are no files to commit by bearomorphism · Pull Request #1969 · commitizen-tools/commitizen

Description: Description Closes #1530. Why cz bump unconditionally calls git commit -a after updating version files, then treats any non-zero exit code as a fatal BumpCommitFailedError. When version_provider = "scm" is configured with no version_files and no changelog generation, there are no files for the bump to modify — so git exits with "nothing to commit, working tree clean" and the error is raised before any tag is ever created. Reported by @loelkes on commitizen 4.8.2 / Python 3.13 / macOS (#1530): the exact error is 2nd git.commit error: "On branch main\nnothing to commit, working tree clean\n". Maintainer @Lee-W confirmed the report ("this is a valid bug"), and @woile linked a prior fix attempt (PR #996) that was never merged. A triage note from the open-issues audit (2026-05-09) found the bug is worse on master (v4.15.1) than the original report described: even the first bump now fails, because newer commitizen versions no longer modify cz.toml during a bump. The version_provider = "scm" workflow is fully documented — the version is derived entirely from git tags and no file is ever written — yet there was no way to use it without also enabling update_changelog_on_bump as a workaround. What changed File Change commitizen/git.py Add has_pending_changes() helper after is_staging_clean (line 311): runs git status --porcelain --untracked-files=no and returns True when there are tracked-file changes that git commit -a would commit commitizen/commands/bump.py Gate the git.commit + retry block (lines 383–399) behind if git.has_pending_changes(): …; emit an out.info message and skip straight to tag creation when the tree is clean tests/commands/test_bump_command.py Add test_bump_skips_commit_when_no_files_changed: two consecutive cz bump --yes calls in a version_provider = "scm" repo both succeed and produce the expected v0.1.0 / v0.1.1 tags How it works git.has_pending_changes() (new function, commitizen/git.py after line 311) runs git status --porcelain --untracked-files=no. The --untracked-files=no flag restricts the query to tracked files — exactly the set that git commit -a would stage and commit. The function returns True if there is any non-empty output, False if the working tree is clean for tracked files. Why not reuse the existing git.is_staging_clean() (commitizen/git.py:308–311)? is_staging_clean runs git diff --cached --name-only, which checks only the index (already-staged changes). git commit -a also commits unstaged modifications to tracked files — for example a file reformatted by a pre-commit hook that wasn't re-staged. git status --porcelain --untracked-files=no covers both cases in a single call, making has_pending_changes the correct guard for git commit -a. Why not treat a non-zero exit from git commit as non-fatal? The existing error path also surfaces genuine commit failures — bad GPG key, locked .git/index, pre-commit hook rejection — as non-zero exit codes. Silently swallowing those would mask real problems. Checking before attempting the commit avoids the ambiguity entirely. The retry path is preserved: the pre-commit-reformatter retry (self.retry and c.return_code != 0 and self.changelog_flag) is moved inside the else branch and continues to work exactly as before — it only runs when there was something to commit and the first attempt failed. When skipping the commit, out.info("No file changes; skipping bump commit and tagging HEAD.") is emitted so the user can see why no bump commit appears in git log. Backward compatibility Repos that have version_files or update_changelog_on_bump = true always have pending changes after the update step; has_pending_changes() returns True and the commit path runs exactly as before. The retry-on-reformat path (self.retry) is preserved intact inside the else branch. Pre-commit hook integration, GPG signing (gpg_sign), and annotated-tag options are unaffected — those code paths all execute after the commit block. git.is_staging_clean() is untouched; nothing that calls it is changed. All pre-existing tests/commands/test_bump_command.py tests pass (132 tests; 4 GPG-fixture tests deselected on Windows — pre-existing, unrelated). Checklist I have read the contributing guidelines Was generative AI tooling used to co-author this PR? Yes (please specify the tool below) Generated-by: Claude 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 (see "Steps to Test" below) Update the documentation for the changes Expected Behavior Scenario Outcome version_provider = "scm", no version_files, no changelog — first cz bump Tag v0.1.0 created on HEAD; no bump commit; exit 0 Same config — second cz bump after another conventional commit Tag v0.1.1 created; no error; exit 0 version_provider = "pep621" with version_files configured — cz bump Behaviour unchanged: version file updated → bump commit created → tag applied version_provider = "scm" with update_changelog_on_bump = true — cz bump Behaviour unchanged: changelog written → has_pending_changes() returns True → bump commit created → tag applied Steps to Test This Pull Request git fetch fork fix/1530-skip-commit-when-clean git checkout fork/fix/1530-skip-commit-when-clean # 1. Targeted regression test. uv run pytest tests/commands/test_bump_command.py::test_bump_skips_commit_when_no_files_changed -v # 2. Reproduce the bug, then verify the fix. mkdir /tmp/cz-1530 && cd /tmp/cz-1530 git init -b main git config user.name test && git config user.email test@example.com printf '[tool.commitizen]\nversion_provider = "scm"\ntag_format = "v$version"\n' > cz.toml git add cz.toml && git commit -m "feat: setup" # First bump — previously failed with BumpCommitFailedError on master. cz bump --yes # Expected: "No file changes; skipping bump commit and tagging HEAD." + exit 0 git tag --list # should show v0.1.0 # Second bump — the scenario from the original report. touch foobar && git add foobar && git commit -m "feat: foobar" cz bump --yes # Expected: exit 0, no "nothing to commit" error git tag --list # should show v0.1.0 and v0.2.0 Additional Context This fix was identified during the open-issues audit tracked in #1964. A triage note (@bearomorphism, 2026-05-09) confirmed the bug reproduces on master (v4.15.1) — and is worse than the original report, failing on the very first bump — and suggested checking is_staging_clean() before the commit. The implementation instead introduces a dedicated git.has_pending_changes() helper using git status --porcelain --untracked-files=no, which correctly covers both staged and unstaged modifications to tracked files (the full set that git commit -a acts on); see the "How it works" section for why the existing is_staging_clean() was insufficient. A prior fix attempt existed as PR #996 but was never merged.

Open Graph Description: Description Closes #1530. Why cz bump unconditionally calls git commit -a after updating version files, then treats any non-zero exit code as a fatal BumpCommitFailedError. When version_provider = ...

X Description: Description Closes #1530. Why cz bump unconditionally calls git commit -a after updating version files, then treats any non-zero exit code as a fatal BumpCommitFailedError. When version_provider = ...

Opengraph URL: https://github.com/commitizen-tools/commitizen/pull/1969

X: @github

direct link

Domain: github.com

route-pattern/:user_id/:repository/pull/:id/files(.:format)
route-controllerpull_requests
route-actionfiles
fetch-noncev2:5dc1e812-6478-9a6e-cbbb-1763849ab9a6
current-catalog-service-hashae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b
request-idD652:33E8BE:C2949:11E9C7:6A4DFAB7
html-safe-nonce794340b00b85478fa2bb7618d0e30e560823e15d68a74f417370510075e0c51b
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJENjUyOjMzRThCRTpDMjk0OToxMUU5Qzc6NkE0REZBQjciLCJ2aXNpdG9yX2lkIjoiMzMxODUzNzg1MjM1MDYxNDMxIiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0=
visitor-hmac6894a053ec6a4c572d7e543af238c0444676e1ae81edd396f9e74e28437bbf6b
hovercard-subject-tagpull_request:3654688835
github-keyboard-shortcutsrepository,pull-request-list,pull-request-conversation,pull-request-files-changed,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///pull_requests/show/files
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/commitizen-tools/commitizen/pull/1969/files
twitter:imagehttps://avatars.githubusercontent.com/u/26526132?s=400&v=4
twitter:cardsummary_large_image
og:imagehttps://avatars.githubusercontent.com/u/26526132?s=400&v=4
og:image:altDescription Closes #1530. Why cz bump unconditionally calls git commit -a after updating version files, then treats any non-zero exit code as a fatal BumpCommitFailedError. When version_provider = ...
og:site_nameGitHub
og:typeobject
hostnamegithub.com
expected-hostnamegithub.com
None5818716c93c6a2925b815402541a32814e43a7b1261c322b0c2df75224289566
turbo-cache-controlno-preview
diff-viewunified
go-importgithub.com/commitizen-tools/commitizen git https://github.com/commitizen-tools/commitizen.git
octolytics-dimension-user_id62252524
octolytics-dimension-user_logincommitizen-tools
octolytics-dimension-repository_id106127589
octolytics-dimension-repository_nwocommitizen-tools/commitizen
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id106127589
octolytics-dimension-repository_network_root_nwocommitizen-tools/commitizen
turbo-body-classeslogged-out env-production page-responsive full-width
disable-turbotrue
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
release4314b1df11fa8a565684f3a72dc971e3785da365
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://github.com/commitizen-tools/commitizen/pull/1969/files#start-of-content
https://github.com/
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fcommitizen-tools%2Fcommitizen%2Fpull%2F1969%2Ffiles
GitHub CopilotWrite better code with AIhttps://github.com/features/copilot
GitHub Copilot appDirect agents from issue to mergehttps://github.com/features/ai/github-app
MCP RegistryNewIntegrate external toolshttps://github.com/mcp
ActionsAutomate any workflowhttps://github.com/features/actions
CodespacesInstant dev environmentshttps://github.com/features/codespaces
IssuesPlan and track workhttps://github.com/features/issues
Code ReviewManage code changeshttps://github.com/features/code-review
GitHub Advanced SecurityFind and fix vulnerabilitieshttps://github.com/security/advanced-security
Code securitySecure your code as you buildhttps://github.com/security/advanced-security/code-security
Secret protectionStop leaks before they starthttps://github.com/security/advanced-security/secret-protection
Why GitHubhttps://github.com/why-github
Documentationhttps://docs.github.com
Bloghttps://github.blog
Changeloghttps://github.blog/changelog
Marketplacehttps://github.com/marketplace
View all featureshttps://github.com/features
Enterpriseshttps://github.com/enterprise
Small and medium teamshttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
App Modernizationhttps://github.com/solutions/use-case/app-modernization
DevSecOpshttps://github.com/solutions/use-case/devsecops
DevOpshttps://github.com/solutions/use-case/devops
CI/CDhttps://github.com/solutions/use-case/ci-cd
View all use caseshttps://github.com/solutions/use-case
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
View all industrieshttps://github.com/solutions/industry
View all solutionshttps://github.com/solutions
AIhttps://github.com/resources/articles?topic=ai
Software Developmenthttps://github.com/resources/articles?topic=software-development
DevOpshttps://github.com/resources/articles?topic=devops
Securityhttps://github.com/resources/articles?topic=security
View all topicshttps://github.com/resources/articles
Customer storieshttps://github.com/customer-stories
Events & webinarshttps://github.com/resources/events
Ebooks & reportshttps://github.com/resources/whitepapers
Business insightshttps://github.com/solutions/executive-insights
GitHub Skillshttps://skills.github.com
Documentationhttps://docs.github.com
Customer supporthttps://support.github.com
Community forumhttps://github.com/orgs/community/discussions
Trust centerhttps://github.com/trust-center
Partnershttps://github.com/partners
View all resourceshttps://github.com/resources
GitHub SponsorsFund open source developershttps://github.com/sponsors
Security Labhttps://securitylab.github.com
Maintainer Communityhttps://maintainers.github.com
Acceleratorhttps://github.com/accelerator
GitHub Starshttps://stars.github.com
Archive Programhttps://archiveprogram.github.com
Topicshttps://github.com/topics
Trendinghttps://github.com/trending
Collectionshttps://github.com/collections
Enterprise platformAI-powered developer platformhttps://github.com/enterprise
GitHub Advanced SecurityEnterprise-grade security featureshttps://github.com/security/advanced-security
Copilot for BusinessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/premium-support
Pricinghttps://github.com/pricing
Search syntax tipshttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
documentationhttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fcommitizen-tools%2Fcommitizen%2Fpull%2F1969%2Ffiles
Sign up https://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fpull_requests%2Fshow%2Ffiles&source=header-repo&source_repo=commitizen-tools%2Fcommitizen
Reloadhttps://github.com/commitizen-tools/commitizen/pull/1969/files
Reloadhttps://github.com/commitizen-tools/commitizen/pull/1969/files
Reloadhttps://github.com/commitizen-tools/commitizen/pull/1969/files
Please reload this pagehttps://github.com/commitizen-tools/commitizen/pull/1969/files
commitizen-tools https://github.com/commitizen-tools
commitizenhttps://github.com/commitizen-tools/commitizen
Please reload this pagehttps://github.com/commitizen-tools/commitizen/pull/1969/files
Notifications https://github.com/login?return_to=%2Fcommitizen-tools%2Fcommitizen
Fork 343 https://github.com/login?return_to=%2Fcommitizen-tools%2Fcommitizen
Star 3.5k https://github.com/login?return_to=%2Fcommitizen-tools%2Fcommitizen
Code https://github.com/commitizen-tools/commitizen
Issues 116 https://github.com/commitizen-tools/commitizen/issues
Pull requests 45 https://github.com/commitizen-tools/commitizen/pulls
Discussions https://github.com/commitizen-tools/commitizen/discussions
Actions https://github.com/commitizen-tools/commitizen/actions
Projects https://github.com/commitizen-tools/commitizen/projects
Security and quality 0 https://github.com/commitizen-tools/commitizen/security
Insights https://github.com/commitizen-tools/commitizen/pulse
Code https://github.com/commitizen-tools/commitizen
Issues https://github.com/commitizen-tools/commitizen/issues
Pull requests https://github.com/commitizen-tools/commitizen/pulls
Discussions https://github.com/commitizen-tools/commitizen/discussions
Actions https://github.com/commitizen-tools/commitizen/actions
Projects https://github.com/commitizen-tools/commitizen/projects
Security and quality https://github.com/commitizen-tools/commitizen/security
Insights https://github.com/commitizen-tools/commitizen/pulse
Sign up for GitHub https://github.com/signup?return_to=%2Fcommitizen-tools%2Fcommitizen%2Fissues%2Fnew%2Fchoose
terms of servicehttps://docs.github.com/terms
privacy statementhttps://docs.github.com/privacy
Sign inhttps://github.com/login?return_to=%2Fcommitizen-tools%2Fcommitizen%2Fissues%2Fnew%2Fchoose
bearomorphismhttps://github.com/bearomorphism
commitizen-tools:masterhttps://github.com/commitizen-tools/commitizen/tree/master
bearomorphism:fix/1530-skip-commit-when-cleanhttps://github.com/bearomorphism/commitizen/tree/fix/1530-skip-commit-when-clean
Conversation 8 https://github.com/commitizen-tools/commitizen/pull/1969
Commits 3 https://github.com/commitizen-tools/commitizen/pull/1969/commits
Checks 20 https://github.com/commitizen-tools/commitizen/pull/1969/checks
Files changed 3 https://github.com/commitizen-tools/commitizen/pull/1969/files
fix(bump): skip commit step when there are no files to commit https://github.com/commitizen-tools/commitizen/pull/1969/files#top
Show all changes 3 commits https://github.com/commitizen-tools/commitizen/pull/1969/files
16b3318 fix(bump): skip commit step when there are no files to commit bearomorphism May 9, 2026 https://github.com/commitizen-tools/commitizen/pull/1969/commits/16b3318a41fb28136f0ebc0dc92bf10cef99faf6
53dd1cb fix(bump): address PR #1969 reviewer feedback bearomorphism May 9, 2026 https://github.com/commitizen-tools/commitizen/pull/1969/commits/53dd1cbb61092dfb273e6f4cb30028c0c24fd07a
c04048c test(bump): cover _stage_updated_files error path bearomorphism May 9, 2026 https://github.com/commitizen-tools/commitizen/pull/1969/commits/c04048c650e511922528fe62a27391f2ab8b0fef
Clear filters https://github.com/commitizen-tools/commitizen/pull/1969/files
Please reload this pagehttps://github.com/commitizen-tools/commitizen/pull/1969/files
Please reload this pagehttps://github.com/commitizen-tools/commitizen/pull/1969/files
bump.py https://github.com/commitizen-tools/commitizen/pull/1969/files#diff-920733205b591ccb6aded23a60aba1c20600036d38b5c224e27da47cf09ffb60
git.py https://github.com/commitizen-tools/commitizen/pull/1969/files#diff-2c36ae6439ace4898e030adb6f7a861fd8e5ae0002ca472cc97e627ea20b3d96
test_bump_command.py https://github.com/commitizen-tools/commitizen/pull/1969/files#diff-8b7a896f7aaf12467a53ab731ce9f5e167dc3afe6e88e06e7700f1a7e9e92831
commitizen/commands/bump.pyhttps://github.com/commitizen-tools/commitizen/pull/1969/files#diff-920733205b591ccb6aded23a60aba1c20600036d38b5c224e27da47cf09ffb60
View file https://github.com/commitizen-tools/commitizen/blob/c04048c650e511922528fe62a27391f2ab8b0fef/commitizen/commands/bump.py
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/commitizen-tools/commitizen/pull/1969/{{ revealButtonHref }}
https://github.com/commitizen-tools/commitizen/pull/1969/files#diff-920733205b591ccb6aded23a60aba1c20600036d38b5c224e27da47cf09ffb60
https://github.com/commitizen-tools/commitizen/pull/1969/files#diff-920733205b591ccb6aded23a60aba1c20600036d38b5c224e27da47cf09ffb60
https://github.com/commitizen-tools/commitizen/pull/1969/files#diff-920733205b591ccb6aded23a60aba1c20600036d38b5c224e27da47cf09ffb60
https://github.com/commitizen-tools/commitizen/pull/1969/files#diff-920733205b591ccb6aded23a60aba1c20600036d38b5c224e27da47cf09ffb60
commitizen/git.pyhttps://github.com/commitizen-tools/commitizen/pull/1969/files#diff-2c36ae6439ace4898e030adb6f7a861fd8e5ae0002ca472cc97e627ea20b3d96
View file https://github.com/commitizen-tools/commitizen/blob/c04048c650e511922528fe62a27391f2ab8b0fef/commitizen/git.py
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/commitizen-tools/commitizen/pull/1969/{{ revealButtonHref }}
https://github.com/commitizen-tools/commitizen/pull/1969/files#diff-2c36ae6439ace4898e030adb6f7a861fd8e5ae0002ca472cc97e627ea20b3d96
https://github.com/commitizen-tools/commitizen/pull/1969/files#diff-2c36ae6439ace4898e030adb6f7a861fd8e5ae0002ca472cc97e627ea20b3d96
tests/commands/test_bump_command.pyhttps://github.com/commitizen-tools/commitizen/pull/1969/files#diff-8b7a896f7aaf12467a53ab731ce9f5e167dc3afe6e88e06e7700f1a7e9e92831
View file https://github.com/commitizen-tools/commitizen/blob/c04048c650e511922528fe62a27391f2ab8b0fef/tests/commands/test_bump_command.py
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/commitizen-tools/commitizen/pull/1969/{{ revealButtonHref }}
https://github.com/commitizen-tools/commitizen/pull/1969/files#diff-8b7a896f7aaf12467a53ab731ce9f5e167dc3afe6e88e06e7700f1a7e9e92831
https://github.com/commitizen-tools/commitizen/pull/1969/files#diff-8b7a896f7aaf12467a53ab731ce9f5e167dc3afe6e88e06e7700f1a7e9e92831
https://github.com/commitizen-tools/commitizen/pull/1969/files#diff-8b7a896f7aaf12467a53ab731ce9f5e167dc3afe6e88e06e7700f1a7e9e92831
https://github.com/commitizen-tools/commitizen/pull/1969/files#diff-8b7a896f7aaf12467a53ab731ce9f5e167dc3afe6e88e06e7700f1a7e9e92831
Please reload this pagehttps://github.com/commitizen-tools/commitizen/pull/1969/files
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.