Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

fix(Init): fix a typo in _ask_version_provider options and remove unnecessary filter #1528

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

Open
wants to merge 1 commit into
base: v4-9-0-test
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 23 additions & 17 deletions commitizen/commands/init.py
Original file line number Diff line number Diff line change
Expand Up @@ -229,16 +229,27 @@ def _ask_tag_format(self, latest_tag: str) -> str:
def _ask_version_provider(self) -> str:
"""Ask for setting: version_provider"""

OPTS = {
"commitizen": "commitizen: Fetch and set version in commitizen config (default)",
"cargo": "cargo: Get and set version from Cargo.toml:project.version field",
"composer": "composer: Get and set version from composer.json:project.version field",
"npm": "npm: Get and set version from package.json:project.version field",
"pep621": "pep621: Get and set version from pyproject.toml:project.version field",
"poetry": "poetry: Get and set version from pyproject.toml:tool.poetry.version field",
"uv": "uv: Get and Get and set version from pyproject.toml and uv.lock",
"scm": "scm: Fetch the version from git and does not need to set it back",
}
options = (
("commitizen", "Fetch and set version in commitizen config (default)"),
("cargo", "Get and set version from Cargo.toml:project.version field"),
(
"composer",
"Get and set version from composer.json:project.version field",
),
("npm", "Get and set version from package.json:project.version field"),
("pep621", "Get and set version from pyproject.toml:project.version field"),
(
"poetry",
"Get and set version from pyproject.toml:tool.poetry.version field",
),
("uv", "Get and set version from pyproject.toml and uv.lock"),
("scm", "Fetch the version from git and does not need to set it back"),
)

choices = [
questionary.Choice(title=f"{value}: {title}", value=value)
for value, title in options
]

default_val = "commitizen"
if self.project_info.is_python:
Expand All @@ -255,16 +266,11 @@ def _ask_version_provider(self) -> str:
elif self.project_info.is_php_composer:
default_val = "composer"

choices = [
questionary.Choice(title=title, value=value)
for value, title in OPTS.items()
]
default = next(filter(lambda x: x.value == default_val, choices))
version_provider: str = questionary.select(
"Choose the source of the version:",
choices=choices,
style=self.cz.style,
default=default,
default=default_val,
).unsafe_ask()
return version_provider

Expand Down Expand Up @@ -294,7 +300,7 @@ def _ask_major_version_zero(self, version: Version) -> bool:
return major_version_zero

def _ask_update_changelog_on_bump(self) -> bool:
"Ask for setting: update_changelog_on_bump"
"""Ask for setting: update_changelog_on_bump"""
update_changelog_on_bump: bool = questionary.confirm(
"Create changelog automatically on bump",
default=True,
Expand Down