Skip to content

refactor(Init): fix unbounded variable in _ask_tag_format #1529

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 2 commits into
base: v4-9-0-test
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
refactor(Init): fix unbounded variable in _ask_tag_format
  • Loading branch information
bearomorphism committed Jun 10, 2025
commit 6f9a3d2cd2320398a1f0c42ebf6c137bc9df76d7
23 changes: 10 additions & 13 deletions commitizen/commands/init.py
Original file line number Diff line number Diff line change
Expand Up @@ -208,23 +208,20 @@ def _ask_tag(self) -> str:
return latest_tag

def _ask_tag_format(self, latest_tag: str) -> str:
is_correct_format = False
if latest_tag.startswith("v"):
tag_format = r"v$version"
is_correct_format = questionary.confirm(
f'Is "{tag_format}" the correct tag format?', style=self.cz.style
).unsafe_ask()
v_tag_format = r"v$version"
if questionary.confirm(
f'Is "{v_tag_format}" the correct tag format?', style=self.cz.style
).unsafe_ask():
return v_tag_format

default_format = DEFAULT_SETTINGS["tag_format"]
if not is_correct_format:
tag_format = questionary.text(
f'Please enter the correct version format: (default: "{default_format}")',
style=self.cz.style,
).unsafe_ask()
tag_format: str = questionary.text(
f'Please enter the correct version format: (default: "{default_format}")',
style=self.cz.style,
).unsafe_ask()

if not tag_format:
tag_format = default_format
return tag_format
return tag_format or default_format

def _ask_version_provider(self) -> str:
"""Ask for setting: version_provider"""
Expand Down