From c2b30e4574b973b5e039dc04d3330a40272d049a Mon Sep 17 00:00:00 2001 From: Ginger Burns Date: Wed, 23 Oct 2024 11:14:55 +0100 Subject: [PATCH 1/3] fix: move breaking to footer to match original schema better. Parsing seems to work either way so this doesn't break any commits made using the previous schema. Closes: #1 --- cz_nhm.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/cz_nhm.py b/cz_nhm.py index 01b6fce..e867451 100644 --- a/cz_nhm.py +++ b/cz_nhm.py @@ -163,11 +163,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)}' @@ -192,10 +192,10 @@ def schema(self) -> str: return ( "(): \n" "\n" - "BREAKING CHANGE: \n" - "\n" "\n" "\n" + "BREAKING CHANGE: \n" + "\n" "Closes: " ) From c39a67c4df3457c70f31de08050bb8ec55606980 Mon Sep 17 00:00:00 2001 From: Ginger Burns Date: Wed, 23 Oct 2024 12:07:45 +0100 Subject: [PATCH 2/3] feat: enable breaking changes with exclamation marks --- cz_nhm.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/cz_nhm.py b/cz_nhm.py index e867451..b7bbb01 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])})' From 8c1b0295d27cc872ed2bd83e55c2d4a9eb3ee99b Mon Sep 17 00:00:00 2001 From: Ginger Burns Date: Wed, 23 Oct 2024 12:08:17 +0100 Subject: [PATCH 3/3] style: fix quotes --- cz_nhm.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/cz_nhm.py b/cz_nhm.py index b7bbb01..482e968 100644 --- a/cz_nhm.py +++ b/cz_nhm.py @@ -193,13 +193,13 @@ def schema(self) -> str: Used by cz schema. """ return ( - "(): \n" - "\n" - "\n" - "\n" - "BREAKING CHANGE: \n" - "\n" - "Closes: " + '(): \n' + '\n' + '\n' + '\n' + 'BREAKING CHANGE: \n' + '\n' + 'Closes: ' ) def schema_pattern(self) -> str: