21
21
22
22
23
23
class CustomizeCommitsCz (BaseCommitizen ):
24
- bump_pattern = defaults .bump_pattern
25
- bump_map = defaults .bump_map
26
- bump_map_major_version_zero = defaults .bump_map_major_version_zero
27
- change_type_order = defaults .change_type_order
28
-
29
24
def __init__ (self , config : BaseConfig ):
30
25
super ().__init__ (config )
31
26
32
27
if "customize" not in self .config .settings :
33
28
raise MissingCzCustomizeConfigError ()
34
29
self .custom_settings = self .config .settings ["customize" ]
35
30
36
- custom_bump_pattern = self . custom_settings . get ( "bump_pattern" )
37
- if custom_bump_pattern :
38
- self . bump_pattern = custom_bump_pattern
39
-
40
- custom_bump_map = self . custom_settings . get ( "bump_map" )
41
- if custom_bump_map :
42
- self . bump_map = custom_bump_map
43
-
44
- custom_bump_map_major_version_zero = self . custom_settings . get (
45
- "bump_map_major_version_zero"
31
+ self . bump_pattern = (
32
+ self . custom_settings . get ( "bump_pattern" ) or defaults . bump_pattern
33
+ )
34
+ self . bump_map = self . custom_settings . get ( "bump_map" ) or defaults . bump_map
35
+ self . bump_map_major_version_zero = (
36
+ self . custom_settings . get ( "bump_map_major_version_zero" )
37
+ or defaults . bump_map_major_version_zero
38
+ )
39
+ self . change_type_order = (
40
+ self . custom_settings . get ( "change_type_order" ) or defaults . change_type_order
46
41
)
47
- if custom_bump_map_major_version_zero :
48
- self .bump_map_major_version_zero = custom_bump_map_major_version_zero
49
-
50
- custom_change_type_order = self .custom_settings .get ("change_type_order" )
51
- if custom_change_type_order :
52
- self .change_type_order = custom_change_type_order
53
42
54
- commit_parser = self .custom_settings .get ("commit_parser" )
55
- if commit_parser :
43
+ if commit_parser := self .custom_settings .get ("commit_parser" ):
56
44
self .commit_parser = commit_parser
57
45
58
- changelog_pattern = self .custom_settings .get ("changelog_pattern" )
59
- if changelog_pattern :
46
+ if changelog_pattern := self .custom_settings .get ("changelog_pattern" ):
60
47
self .changelog_pattern = changelog_pattern
61
48
62
- change_type_map = self .custom_settings .get ("change_type_map" )
63
- if change_type_map :
49
+ if change_type_map := self .custom_settings .get ("change_type_map" ):
64
50
self .change_type_map = change_type_map
65
51
66
52
def questions (self ) -> Questions :
@@ -83,12 +69,7 @@ def schema(self) -> str:
83
69
return self .custom_settings .get ("schema" ) or ""
84
70
85
71
def info (self ) -> str :
86
- info_path = self .custom_settings .get ("info_path" )
87
- info = self .custom_settings .get ("info" )
88
- if info_path :
72
+ if info_path := self .custom_settings .get ("info_path" ):
89
73
with open (info_path , encoding = self .config .settings ["encoding" ]) as f :
90
- content = f .read ()
91
- return content
92
- elif info :
93
- return info
94
- return ""
74
+ return f .read ()
75
+ return self .custom_settings .get ("info" ) or ""
0 commit comments