8
8
@pytest .fixture (scope = "module" )
9
9
def config ():
10
10
_conf = Config ()
11
- toml_str = """
11
+ toml_str = r """
12
12
[tool.commitizen.customize]
13
13
# message_template should follow the python string formatting spec
14
- message_template = "{{change_type}}: {{message}}"
14
+ message_template = "{{change_type}}:{% if show_message %} {{message}}{% endif % }"
15
15
example = "feature: this feature eanable customize through config file"
16
16
schema = "<type>: <body>"
17
17
bump_pattern = "^(break|new|fix|hotfix)"
@@ -31,6 +31,11 @@ def config():
31
31
type = "input"
32
32
name = "message"
33
33
message = "Body."
34
+
35
+ [[tool.commitizen.customize.questions]]
36
+ type = "confirm"
37
+ name = "show_message"
38
+ message = "Do you want to add body message in commit?"
34
39
"""
35
40
_conf .update (parse (toml_str )["tool" ]["commitizen" ])
36
41
return _conf .config
@@ -65,6 +70,11 @@ def test_questions(config):
65
70
"message" : "Select the type of change you are committing" ,
66
71
},
67
72
{"type" : "input" , "name" : "message" , "message" : "Body." },
73
+ {
74
+ "type" : "confirm" ,
75
+ "name" : "show_message" ,
76
+ "message" : "Do you want to add body message in commit?" ,
77
+ },
68
78
]
69
79
assert list (questions ) == expected_questions
70
80
@@ -74,10 +84,20 @@ def test_answer(config):
74
84
answers = {
75
85
"change_type" : "feature" ,
76
86
"message" : "this feature eanable customize through config file" ,
87
+ "show_message" : True ,
77
88
}
78
89
message = cz .message (answers )
79
90
assert message == "feature: this feature eanable customize through config file"
80
91
92
+ cz = CustomizeCommitsCz (config )
93
+ answers = {
94
+ "change_type" : "feature" ,
95
+ "message" : "this feature eanable customize through config file" ,
96
+ "show_message" : False ,
97
+ }
98
+ message = cz .message (answers )
99
+ assert message == "feature:"
100
+
81
101
82
102
def test_example (config ):
83
103
cz = CustomizeCommitsCz (config )
0 commit comments