René's URL Explorer Experiment


Title: fix(bump): flag sibling version mismatches under --check-consistency by bearomorphism · Pull Request #1978 · commitizen-tools/commitizen · GitHub

Open Graph Title: fix(bump): flag sibling version mismatches under --check-consistency by bearomorphism · Pull Request #1978 · commitizen-tools/commitizen

X Title: fix(bump): flag sibling version mismatches under --check-consistency by bearomorphism · Pull Request #1978 · commitizen-tools/commitizen

Description: Description Closes #595. Why commitizen/bump.py:update_version_in_files applies a regex pattern to each line of every file in version_files. When a broad pattern such as pyproject.toml:version is used, the regex legitimately matches multiple version = lines — one under [tool.commitizen] holding the current commitizen-managed version, and one under [tool.poetry] (or [project] for PEP-621) holding a potentially out-of-sync value maintained by a different tool. The old inner loop (master commitizen/bump.py:88-95) replaced the current_version string wherever pattern.search(line) was true and set current_version_found only when the replacement changed the line. The loop never inspected lines that matched the pattern but did not contain current_version, so the [tool.poetry].version line was silently skipped — the bump proceeded, --check-consistency raised no error, and the file was left with two different version strings. The original reporter @gpongelli observed the mismatch in commitizen 2.34.0; maintainer @Lee-W confirmed the reproduction and noted that the regex-based approach made a proper same-file consistency check architecturally difficult. A follow-up comment from @woile noted the workaround (use a more specific regex such as pyproject.toml:\[tool\.poetry\][.\s\D]*^version). The triage audit on #1964 confirmed the issue is still present in master (v4.15.1): a pyproject.toml with [tool.poetry].version = "2.5.7" and [tool.commitizen].version = "2.5.2" running cz bump --check-consistency --yes exits 0, bumps commitizen's version to 2.6.0, and leaves the poetry version at 2.5.7 — still mismatched and silent. This PR narrows the fix: when check_consistency=True, any line that (a) matches the version-files regex and (b) does not contain current_version but (c) contains a semver-shaped value is collected as an inconsistent_lines entry. If any such entries exist after processing the file, CurrentVersionNotFoundError is raised with a message that names the file path, the line number, and the offending version string so the user knows exactly which tool is out of sync. The default path (check_consistency=False) is completely unchanged. What changed File Change commitizen/bump.py Refactor inner loop (was lines 88–95) to enumerate lines and track inconsistent_lines; add _LIKELY_VERSION_VALUE_RE module-level constant; raise CurrentVersionNotFoundError with line-level details when check_consistency=True and sibling mismatches are found tests/test_bump_update_version_in_files.py Two new regression tests: sibling detection raises with both version strings in the error message; legacy no-check_consistency behaviour leaves sibling untouched without raising How it works Two-phase consistency check. The existing check (master commitizen/bump.py:98-103) validates that at least one line was updated — i.e., current_version was found. The new check is a second gate that validates that no other line looks like it stores a different version. Both checks run after the full file is read, before any write occurs, so a failed consistency check always leaves the file on disk untouched. _LIKELY_VERSION_VALUE_RE is intentionally conservative. The regex \d+\.\d+\.\d+(?:[\w.\-+]*) matches the canonical MAJOR.MINOR.PATCH semver shape (plus optional pre-release and build-metadata suffixes). It deliberately does not match bare integers, Python import paths, comment prose, or generic version = keywords without a version-shaped right-hand side. This prevents false positives from unrelated occurrences of the word version in configuration comments or code that the user's regex happens to match. Line numbers are 1-based in the error message. enumerate(version_file, 1) is used so that the reported line number matches what editors and grep -n report. This makes the error message actionable without requiring the user to open the file and count from zero. check_consistency=False path is byte-for-byte identical to the old behaviour. The inconsistent_lines list is only evaluated inside the if check_consistency block. No code runs on the fast path for users who do not pass --check-consistency. Why not a TOML-aware parser? @woile and @Lee-W discussed this in the issue thread: a format-specific parser (TOML, JSON, YAML) would add maintenance burden and break the general version_files: any-file contract. The regex approach is deliberately format-agnostic; the conservative _LIKELY_VERSION_VALUE_RE secondary filter is enough to catch the common pyproject.toml case without committing to TOML semantics. Backward compatibility check_consistency=False (the default) preserves the legacy behaviour exactly: only lines containing current_version are rewritten; sibling lines are left alone; no exception is raised. The new CurrentVersionNotFoundError message format is a superset of the existing one — both state the file path and the fact that the version wasn't found; the new message additionally names the offending line. All pre-existing update_version_in_files tests and bump command tests pass unchanged. No CLI flags or configuration keys are added; --check-consistency is the existing flag whose scope is extended. 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 pyproject.toml with [tool.poetry].version = "2.5.7" and [tool.commitizen].version = "2.5.2", version_files = ["pyproject.toml:version"], cz bump --check-consistency Exits non-zero; error message names line 2: version = "2.5.7" as the inconsistent entry; file is not modified Same setup, cz bump (no --check-consistency) Bumps only the commitizen version line; poetry line is left at 2.5.7; no exception — legacy behaviour preserved Single version = line in file, cz bump --check-consistency Works as before — inconsistent_lines is empty, no new error version_files regex narrowed to pyproject.toml:\[tool\.commitizen\] Poetry line never matches the regex; inconsistent_lines is empty regardless of --check-consistency Steps to Test This Pull Request git fetch fork fix/595-check-consistency-version-mismatch git checkout fork/fix/595-check-consistency-version-mismatch # 1. Targeted regression tests. uv run pytest \ tests/test_bump_update_version_in_files.py::test_update_version_in_files_check_consistency_detects_sibling_version \ tests/test_bump_update_version_in_files.py::test_update_version_in_files_check_consistency_off_keeps_legacy_behaviour \ -v # 2. Reproduce-the-bug-then-verify-the-fix sequence (exact scenario from #595). mkdir cz595 && cd cz595 git init -b main git config user.name test && git config user.email test@example.com cat > pyproject.toml << 'EOF' [tool.poetry] name = "cool_proj" version = "2.5.7" [tool.commitizen] name = "cz_conventional_commits" version = "2.5.2" version_files = ["pyproject.toml:version"] EOF git add pyproject.toml && git commit -m "feat: initial setup" # Before fix: exits 0, silently bumps commitizen version only, leaves poetry at 2.5.7. # After fix: exits non-zero, prints offending line (version = "2.5.7"), file untouched. cz bump --check-consistency --yes # Verify file was NOT modified on failure: grep 'version = "2.5.2"' pyproject.toml # must still be present # Verify legacy behaviour (no --check-consistency) is unchanged: cz bump --yes grep 'version = "2.6.0"' pyproject.toml # commitizen line bumped grep 'version = "2.5.7"' pyproject.toml # poetry line untouched — expected Additional Context This fix was scoped during the issue audit in #1964, which confirmed the silent-pass behaviour is still present in master (v4.15.1). The implementation deliberately stays within the existing regex-based version_files contract rather than introducing format-specific parsing, consistent with the design discussion in the #595 thread (@woile, @Lee-W). Users whose version_files regex is already specific enough to target only the commitizen-managed line are unaffected — their _LIKELY_VERSION_VALUE_RE scan will find no inconsistent lines.

Open Graph Description: Description Closes #595. Why commitizen/bump.py:update_version_in_files applies a regex pattern to each line of every file in version_files. When a broad pattern such as pyproject.toml:version is u...

X Description: Description Closes #595. Why commitizen/bump.py:update_version_in_files applies a regex pattern to each line of every file in version_files. When a broad pattern such as pyproject.toml:version is u...

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

X: @github

direct link

Domain: github.com

route-pattern/:user_id/:repository/pull/:id/files(.:format)
route-controllerpull_requests
route-actionfiles
fetch-noncev2:0c215413-6fc0-745c-f854-483223e808f5
current-catalog-service-hashae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b
request-id8FF8:73567:C40CBC:1205B70:6A4E2665
html-safe-nonce18c553a17e858c1ffff86b5c78f895895b93fb272182f4bf331cb416b7e3f0b8
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4RkY4OjczNTY3OkM0MENCQzoxMjA1QjcwOjZBNEUyNjY1IiwidmlzaXRvcl9pZCI6IjQ2NDM4NzY2MTExMTU4NTM0MTMiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ==
visitor-hmac5162cef9e3c991cb93b235f4b9623082da870ade173001e24113a2517b18fcb7
hovercard-subject-tagpull_request:3654770223
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/1978/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 #595. Why commitizen/bump.py:update_version_in_files applies a regex pattern to each line of every file in version_files. When a broad pattern such as pyproject.toml:version is u...
og:site_nameGitHub
og:typeobject
hostnamegithub.com
expected-hostnamegithub.com
None030096ee0db095447bfe77409d33bfac127ca7128299c58deef27c52eaa1b1f0
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
released9dd20d38f8ae3c4cb6b597807431db300d0bd2a
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://github.com/commitizen-tools/commitizen/pull/1978/files#start-of-content
https://github.com/
Sign in https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fcommitizen-tools%2Fcommitizen%2Fpull%2F1978%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%2F1978%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/1978/files
Reloadhttps://github.com/commitizen-tools/commitizen/pull/1978/files
Reloadhttps://github.com/commitizen-tools/commitizen/pull/1978/files
Please reload this pagehttps://github.com/commitizen-tools/commitizen/pull/1978/files
commitizen-tools https://github.com/commitizen-tools
commitizenhttps://github.com/commitizen-tools/commitizen
Please reload this pagehttps://github.com/commitizen-tools/commitizen/pull/1978/files
Notifications https://github.com/login?return_to=%2Fcommitizen-tools%2Fcommitizen
Fork 344 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/595-check-consistency-version-providerhttps://github.com/bearomorphism/commitizen/tree/fix/595-check-consistency-version-provider
Conversation 6 https://github.com/commitizen-tools/commitizen/pull/1978
Commits 2 https://github.com/commitizen-tools/commitizen/pull/1978/commits
Checks 20 https://github.com/commitizen-tools/commitizen/pull/1978/checks
Files changed https://github.com/commitizen-tools/commitizen/pull/1978/files
Please reload this pagehttps://github.com/commitizen-tools/commitizen/pull/1978/files
fix(bump): flag sibling version mismatches under --check-consistency https://github.com/commitizen-tools/commitizen/pull/1978/files#top
Show all changes 2 commits https://github.com/commitizen-tools/commitizen/pull/1978/files
b088993 fix(bump): flag sibling version mismatches under --check-consistency bearomorphism May 9, 2026 https://github.com/commitizen-tools/commitizen/pull/1978/commits/b08899303dcdc1e3fcdc512129549da894783ec5
ceeefb0 fix(bump): guard sibling-mismatch detection behind check_consistency,… bearomorphism May 9, 2026 https://github.com/commitizen-tools/commitizen/pull/1978/commits/ceeefb012b173ed619a9b80c16d44273a3a65eb4
Clear filters https://github.com/commitizen-tools/commitizen/pull/1978/files
Please reload this pagehttps://github.com/commitizen-tools/commitizen/pull/1978/files
Please reload this pagehttps://github.com/commitizen-tools/commitizen/pull/1978/files
bump.py https://github.com/commitizen-tools/commitizen/pull/1978/files#diff-ed9bead31489109a8441fbfb00d2ddec00198489b0702bab164825c2d3bd9b4f
test_bump_update_version_in_files.py https://github.com/commitizen-tools/commitizen/pull/1978/files#diff-36cd67a3bfb620b346e00fc0a0cd9f37b9e7180a272740c95cf838ab3c0b7b58
commitizen/bump.pyhttps://github.com/commitizen-tools/commitizen/pull/1978/files#diff-ed9bead31489109a8441fbfb00d2ddec00198489b0702bab164825c2d3bd9b4f
View file https://github.com/commitizen-tools/commitizen/blob/ceeefb012b173ed619a9b80c16d44273a3a65eb4/commitizen/bump.py
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/commitizen-tools/commitizen/pull/1978/{{ revealButtonHref }}
https://github.com/commitizen-tools/commitizen/pull/1978/files#diff-ed9bead31489109a8441fbfb00d2ddec00198489b0702bab164825c2d3bd9b4f
Please reload this pagehttps://github.com/commitizen-tools/commitizen/pull/1978/files
https://github.com/commitizen-tools/commitizen/pull/1978/files#diff-ed9bead31489109a8441fbfb00d2ddec00198489b0702bab164825c2d3bd9b4f
https://github.com/commitizen-tools/commitizen/pull/1978/files#diff-ed9bead31489109a8441fbfb00d2ddec00198489b0702bab164825c2d3bd9b4f
https://github.com/commitizen-tools/commitizen/pull/1978/files#diff-ed9bead31489109a8441fbfb00d2ddec00198489b0702bab164825c2d3bd9b4f
tests/test_bump_update_version_in_files.pyhttps://github.com/commitizen-tools/commitizen/pull/1978/files#diff-36cd67a3bfb620b346e00fc0a0cd9f37b9e7180a272740c95cf838ab3c0b7b58
View file https://github.com/commitizen-tools/commitizen/blob/ceeefb012b173ed619a9b80c16d44273a3a65eb4/tests/test_bump_update_version_in_files.py
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://github.com/commitizen-tools/commitizen/pull/1978/{{ revealButtonHref }}
https://github.com/commitizen-tools/commitizen/pull/1978/files#diff-36cd67a3bfb620b346e00fc0a0cd9f37b9e7180a272740c95cf838ab3c0b7b58
https://github.com/commitizen-tools/commitizen/pull/1978/files#diff-36cd67a3bfb620b346e00fc0a0cd9f37b9e7180a272740c95cf838ab3c0b7b58
Please reload this pagehttps://github.com/commitizen-tools/commitizen/pull/1978/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.