diff --git a/cz_nhm.py b/cz_nhm.py index 01b6fce..482e968 100644 --- a/cz_nhm.py +++ b/cz_nhm.py @@ -4,6 +4,8 @@ from commitizen.cz.base import BaseCommitizen from commitizen.cz.utils import multiple_line_breaker, required_validator +from commitizen import defaults as cz_defaults +from collections import OrderedDict # CHANGE TYPES ========================================================================= @@ -89,10 +91,11 @@ def parse_scope(text): class NHMCz(BaseCommitizen): - bump_pattern = ( - rf'^({"|".join([c.short_name for c in change_types if c.bump_type])})' + bump_pattern = cz_defaults.bump_pattern + bump_map = OrderedDict( + [(r'^.+!$', 'MAJOR')] + + [(f'^{c.short_name}', c.bump_type) for c in change_types if c.bump_type] ) - bump_map = {c.short_name: c.bump_type for c in change_types if c.bump_type} commit_parser = rf'^(?P{"|".join([c.short_name for c in change_types if c.display_name])})(?:\((?P[^)\r\n]+)\))?: (?P[^\n]+)' changelog_pattern = ( rf'^({"|".join([c.short_name for c in change_types if c.display_name])})' @@ -163,11 +166,11 @@ def message(self, answers: dict) -> str: if scope: message += f'({scope})' message += f': {subject}' + if body: + message += f'\n\n{body}' if is_breaking_change: # repeat the subject so the changelog can pick it up message += f'\n\nBREAKING CHANGE: {subject}' - if body: - message += f'\n\n{body}' if len(issues) > 0: message += f'\n\nCloses: #{", #".join(issues)}' @@ -190,13 +193,13 @@ def schema(self) -> str: Used by cz schema. """ return ( - "(): \n" - "\n" - "BREAKING CHANGE: \n" - "\n" - "\n" - "\n" - "Closes: " + '(): \n' + '\n' + '\n' + '\n' + 'BREAKING CHANGE: \n' + '\n' + 'Closes: ' ) def schema_pattern(self) -> str: