22
33import os
44import shutil
5- from typing import Any
65
76import questionary
87import yaml
@@ -120,21 +119,6 @@ def __call__(self) -> None:
120119 self .config = JsonConfig (data = "{}" , path = config_path )
121120 elif "yaml" in config_path :
122121 self .config = YAMLConfig (data = "" , path = config_path )
123- values_to_add : dict [str , Any ] = {}
124- values_to_add ["name" ] = cz_name
125- values_to_add ["tag_format" ] = tag_format
126- values_to_add ["version_scheme" ] = version_scheme
127-
128- if version_provider == "commitizen" :
129- values_to_add ["version" ] = version .public
130- else :
131- values_to_add ["version_provider" ] = version_provider
132-
133- if update_changelog_on_bump :
134- values_to_add ["update_changelog_on_bump" ] = update_changelog_on_bump
135-
136- if major_version_zero :
137- values_to_add ["major_version_zero" ] = major_version_zero
138122
139123 # Collect hook data
140124 hook_types = questionary .checkbox (
@@ -152,7 +136,18 @@ def __call__(self) -> None:
152136
153137 # Create and initialize config
154138 self .config .init_empty_config_content ()
155- self ._update_config_file (values_to_add )
139+
140+ self .config .set_key ("name" , cz_name )
141+ self .config .set_key ("tag_format" , tag_format )
142+ self .config .set_key ("version_scheme" , version_scheme )
143+ if version_provider == "commitizen" :
144+ self .config .set_key ("version" , version .public )
145+ else :
146+ self .config .set_key ("version_provider" , version_provider )
147+ if update_changelog_on_bump :
148+ self .config .set_key ("update_changelog_on_bump" , update_changelog_on_bump )
149+ if major_version_zero :
150+ self .config .set_key ("major_version_zero" , major_version_zero )
156151
157152 out .write ("\n You can bump the version running:\n " )
158153 out .info ("\t cz bump\n " )
@@ -368,7 +363,3 @@ def _install_pre_commit_hook(self, hook_types: list[str] | None = None) -> None:
368363 hook_types = ["commit-msg" , "pre-push" ]
369364 self ._exec_install_pre_commit_hook (hook_types )
370365 out .write ("commitizen pre-commit hook is now installed in your '.git'\n " )
371-
372- def _update_config_file (self , values : dict [str , Any ]) -> None :
373- for key , value in values .items ():
374- self .config .set_key (key , value )
0 commit comments