-
-
Notifications
You must be signed in to change notification settings - Fork 334
feat(cli): add description when choosing a commit rule #1825
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 4 commits
b695314
31247ee
88532dc
aef0171
c3c9635
774ba66
aa68f32
13c9303
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -11,7 +11,10 @@ | |
| from commitizen.config.factory import create_config | ||
| from commitizen.cz import registry | ||
| from commitizen.defaults import CONFIG_FILES, DEFAULT_SETTINGS | ||
| from commitizen.exceptions import InitFailedError, NoAnswersError | ||
| from commitizen.exceptions import ( | ||
| InitFailedError, | ||
| NoAnswersError, | ||
| ) | ||
| from commitizen.git import get_latest_tag_name, get_tag_names, smart_open | ||
| from commitizen.version_schemes import KNOWN_SCHEMES, Version, get_version_scheme | ||
|
|
||
|
|
@@ -165,9 +168,25 @@ def _ask_config_path(self) -> Path: | |
| return Path(filename) | ||
|
|
||
| def _ask_name(self) -> str: | ||
| def construct_choice_with_description(cz_name: str) -> questionary.Choice: | ||
| try: | ||
| cz_class = registry.get(cz_name) | ||
| if cz_class: | ||
| cz_obj = cz_class(self.config) | ||
| first_example = cz_obj.schema().partition("\n")[0] | ||
| return questionary.Choice( | ||
| title=cz_name, value=cz_name, description=f"{first_example}" | ||
| ) | ||
| except Exception: # pylint: disable=broad-except | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. quick question: what are possible exceptions the
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. cz_obj = cz_class(self.config) could cause exception |
||
| pass | ||
| return questionary.Choice(title=cz_name, value=cz_name) | ||
|
|
||
| name: str = questionary.select( | ||
| "Please choose a cz (commit rule): (default: cz_conventional_commits)", | ||
| choices=list(registry.keys()), | ||
| choices=[ | ||
| construct_choice_with_description(cz_name) | ||
| for cz_name in registry.keys() | ||
| ], | ||
| default="cz_conventional_commits", | ||
| style=self.cz.style, | ||
| ).unsafe_ask() | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.