[feature/refactor] Use named capture group in bump_pattern to enable stricter check
See original GitHub issueGoal make regular expression pattern stricter so that we won’t accidentally match things we don’t need
Description
In commitizen/cz/conventional_commits/conventional_commits.py#L33 on command-changelog
branch, I use named capture group so that we could use a stricter regular expression like .*\n\nBREAKING CHANGE
. The benefit of it is that we don’t have to break the whole commit message into lines like commitizem/bump.py#L31. It can also avoid bump or generate changelog based on commit message like fix --- it does not follow the rule but still match the pattern
.
Another thought on this topic is that we probably merge the bump_map
and bump_pattern
into one some data class to store name
(e.g., break
), pattern
(e.g., .*\n\nBREAKING CHANGE
), behavior
(e.g., PATCH
).
Issue Analytics
- State:
- Created 4 years ago
- Comments:6 (6 by maintainers)
Things like
(?P<MAJOR>^.*\n\nBREAKING[-]CHANGE.*|)|(?P<MINOR>^feat.*)
, but not yet testesd.I’m working on this refactoring in #203 . (I’ve not yet get to the dataclass part.) IMO, dataclass is a stricter solution and less error-prone. It explicitly indicates the type of each configuration. I’ll give you an example once I implement a prototype
It seems we do not need to parse the message when we bump the project version. All we want to know is which version (i.e.
MAJOR
,MINOR
,PATCH
) to bump. What we need to know if whether these types (e.g.,MAJOR
,MINOR
,PATCH
) of commits exist.