Skip to content

Commit aa68f32

Browse files
committed
chore: move construct_choice_with_description outside of _ask_name
1 parent 774ba66 commit aa68f32

File tree

1 file changed

+17
-17
lines changed

1 file changed

+17
-17
lines changed

commitizen/commands/init.py

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -169,30 +169,30 @@ def _ask_config_path(self) -> Path:
169169
return Path(filename)
170170

171171
def _ask_name(self) -> str:
172-
def construct_choice_with_description() -> list[questionary.Choice]:
173-
choices = []
174-
for cz_name, cz_class in registry.items():
175-
try:
176-
cz_obj = cz_class(self.config)
177-
except MissingCzCustomizeConfigError:
178-
choices.append(questionary.Choice(title=cz_name, value=cz_name))
179-
continue
180-
first_example = cz_obj.schema().partition("\n")[0]
181-
choices.append(
182-
questionary.Choice(
183-
title=cz_name, value=cz_name, description=first_example
184-
)
185-
)
186-
return choices
187-
188172
name: str = questionary.select(
189173
"Please choose a cz (commit rule): (default: cz_conventional_commits)",
190-
choices=construct_choice_with_description(),
174+
choices=self._construct_name_choice_with_description(),
191175
default="cz_conventional_commits",
192176
style=self.cz.style,
193177
).unsafe_ask()
194178
return name
195179

180+
def _construct_name_choice_with_description(self) -> list[questionary.Choice]:
181+
choices = []
182+
for cz_name, cz_class in registry.items():
183+
try:
184+
cz_obj = cz_class(self.config)
185+
except MissingCzCustomizeConfigError:
186+
choices.append(questionary.Choice(title=cz_name, value=cz_name))
187+
continue
188+
first_example = cz_obj.schema().partition("\n")[0]
189+
choices.append(
190+
questionary.Choice(
191+
title=cz_name, value=cz_name, description=first_example
192+
)
193+
)
194+
return choices
195+
196196
def _ask_tag(self) -> str:
197197
latest_tag = get_latest_tag_name()
198198
if not latest_tag:

0 commit comments

Comments
 (0)