1
1
from __future__ import annotations
2
2
3
+ from commitizen .cz .conventional_commits import ConventionalCommitsCz
4
+
3
5
try :
4
6
from jinja2 import Template
5
7
except ImportError :
6
8
from string import Template # type: ignore
7
9
8
10
9
- from commitizen import defaults
10
11
from commitizen .config import BaseConfig
11
- from commitizen .cz .base import BaseCommitizen
12
12
from commitizen .defaults import Questions
13
13
from commitizen .exceptions import MissingCzCustomizeConfigError
14
14
15
15
__all__ = ["CustomizeCommitsCz" ]
16
16
17
17
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 ):
24
19
def __init__ (self , config : BaseConfig ):
25
20
super ().__init__ (config )
26
21
@@ -59,25 +54,40 @@ def __init__(self, config: BaseConfig):
59
54
self .change_type_map = change_type_map
60
55
61
56
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 ()
63
61
64
62
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 :
81
91
info_path = self .custom_settings .get ("info_path" )
82
92
info = self .custom_settings .get ("info" )
83
93
if info_path :
@@ -86,4 +96,4 @@ def info(self) -> str | None:
86
96
return content
87
97
elif info :
88
98
return info
89
- return None
99
+ return super (). info ()
0 commit comments