fix(cz_customize): set commit_parser default that captures change_type#1970
Open
bearomorphism wants to merge 1 commit intocommitizen-tools:masterfrom
Open
Conversation
CustomizeCommitsCz previously inherited the `commit_parser =
r"(?P<message>.*)"` default from `BaseCommitizen`. That default
matches everything but does not capture a `change_type` named group,
so even when a `cz_customize` user configured `changelog_pattern`,
`change_type_map` and `change_type_order`, the changelog generator
could not group commits and emitted a single ungrouped bullet list.
Set a conventional-commits-style default that captures
`change_type`, `scope`, `breaking` and `message` named groups.
Users with a different commit format can still override via
`customize.commit_parser`.
End-to-end check on the exact reproducer from the issue now produces a
properly grouped changelog:
## Unreleased
### feat
- **DL-4567**: new feature test
### fix
- **DL-1234**: qweqwe
### chore
- update deps
Closes commitizen-tools#466
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #1970 +/- ##
=======================================
Coverage 98.23% 98.23%
=======================================
Files 61 61
Lines 2779 2780 +1
=======================================
+ Hits 2730 2731 +1
Misses 49 49 ☔ View full report in Codecov by Sentry. |
15 tasks
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
Set a conventional-commits-style default for
CustomizeCommitsCz.commit_parserso thatcz_customizeusers who configurechangelog_pattern(and optionallychange_type_map/change_type_order) but do not set their owncommit_parserstill get a changelog grouped by change type.CustomizeCommitsCzpreviously inheritedcommit_parser = r"(?P<message>.*)"fromBaseCommitizen. That default had nochange_typenamed group, so the changelog generator (incommitizen/changelog.py::_render_into_changelog_tree) couldn't extract achange_typeto group by — every commit ended up underchange_type = Noneand the changelog rendered as a single ungrouped bullet list. This was the exact failure mode in #466.Checklist
Was generative AI tooling used to co-author this PR?
Generated-by: GitHub Copilot CLI (Claude Opus 4.7) following the guidelines
Code Changes
uv run poe lintlocally; CI matrix (3.10–3.14 × linux/macOS/windows) passescommit_parserconfiguredcz_customizetests still pass; users who provided their owncommit_parsersee no changecustomize.mddocs already describecommit_parser; the new default is described in the code docstring)Expected Behavior
End-to-end on the exact repro from the issue (cz_customize with
changelog_pattern+change_type_order, no explicitcommit_parser):(Previously: a single ungrouped bullet list, no
### feat/### fix/### choreheadings.)Steps to Test This Pull Request
mkdir test && cd test && git init -b main && git config user.{name,email} test.cz.yaml:feat: ...,fix(scope): ...).cz changelog --dry-run— output should be grouped by### feat,### fix, etc.Additional Context
Closes #466.
Implementation:
Same shape as the
cz_conventional_commitsparser, but with\w+instead of a fixed type alternation, so it works for anycz_customizeschema that follows<type>(<scope>)?!?: <message>. Users with non-conventional commit formats can still override viacustomize.commit_parser.