11from __future__ import annotations
22
3+ from commitizen .cz .conventional_commits import ConventionalCommitsCz
4+
35try :
46 from jinja2 import Template
57except ImportError :
68 from string import Template # type: ignore
79
810
9- from commitizen import defaults
1011from commitizen .config import BaseConfig
11- from commitizen .cz .base import BaseCommitizen
1212from commitizen .defaults import Questions
1313from commitizen .exceptions import MissingCzCustomizeConfigError
1414
1515__all__ = ["CustomizeCommitsCz" ]
1616
1717
18- class CustomizeCommitsCz (BaseCommitizen ):
19- bump_pattern = defaults .bump_pattern
20- bump_map = defaults .bump_map
21- bump_map_major_version_zero = defaults .bump_map_major_version_zero
22- change_type_order = defaults .change_type_order
23-
18+ class CustomizeCommitsCz (ConventionalCommitsCz ):
2419 def __init__ (self , config : BaseConfig ):
2520 super ().__init__ (config )
2621
@@ -59,25 +54,40 @@ def __init__(self, config: BaseConfig):
5954 self .change_type_map = change_type_map
6055
6156 def questions (self ) -> Questions :
62- return self .custom_settings .get ("questions" , [{}])
57+ custom_questions = self .custom_settings .get ("questions" , [{}])
58+ if custom_questions :
59+ return custom_questions
60+ return super ().questions ()
6361
6462 def message (self , answers : dict ) -> str :
65- message_template = Template (self .custom_settings .get ("message_template" , "" ))
66- if getattr (Template , "substitute" , None ):
67- return message_template .substitute (** answers ) # type: ignore
68- else :
69- return message_template .render (** answers )
70-
71- def example (self ) -> str | None :
72- return self .custom_settings .get ("example" )
73-
74- def schema_pattern (self ) -> str | None :
75- return self .custom_settings .get ("schema_pattern" )
76-
77- def schema (self ) -> str | None :
78- return self .custom_settings .get ("schema" )
79-
80- def info (self ) -> str | None :
63+ custom_message = self .custom_settings .get ("message_template" )
64+ if custom_message :
65+ message_template = Template (custom_message )
66+ if getattr (Template , "substitute" , None ):
67+ return message_template .substitute (** answers ) # type: ignore
68+ else :
69+ return message_template .render (** answers )
70+ return super ().message (answers )
71+
72+ def example (self ) -> str :
73+ custom_example = self .custom_settings .get ("example" )
74+ if custom_example :
75+ return custom_example
76+ return super ().example ()
77+
78+ def schema_pattern (self ) -> str :
79+ custom_schema_pattern = self .custom_settings .get ("schema_pattern" )
80+ if custom_schema_pattern :
81+ return custom_schema_pattern
82+ return super ().schema_pattern ()
83+
84+ def schema (self ) -> str :
85+ custom_schema = self .custom_settings .get ("schema" )
86+ if custom_schema :
87+ return custom_schema
88+ return super ().schema ()
89+
90+ def info (self ) -> str :
8191 info_path = self .custom_settings .get ("info_path" )
8292 info = self .custom_settings .get ("info" )
8393 if info_path :
@@ -86,4 +96,4 @@ def info(self) -> str | None:
8696 return content
8797 elif info :
8898 return info
89- return None
99+ return super (). info ()
0 commit comments