Skip to content
Merged
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
11 changes: 11 additions & 0 deletions commitizen/commands/init.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ class ProjectInfo:
def has_pyproject(self) -> bool:
return os.path.isfile("pyproject.toml")

@property
def has_uv_lock(self) -> bool:
return os.path.isfile("uv.lock")

@property
def has_setup(self) -> bool:
return os.path.isfile("setup.py")
Expand All @@ -32,6 +36,10 @@ def has_setup(self) -> bool:
def has_pre_commit_config(self) -> bool:
return os.path.isfile(".pre-commit-config.yaml")

@property
def is_python_uv(self) -> bool:
return self.has_pyproject and self.has_uv_lock

@property
def is_python_poetry(self) -> bool:
if not self.has_pyproject:
Expand Down Expand Up @@ -228,13 +236,16 @@ def _ask_version_provider(self) -> str:
"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",
}

default_val = "commitizen"
if self.project_info.is_python:
if self.project_info.is_python_poetry:
default_val = "poetry"
elif self.project_info.is_python_uv:
default_val = "uv"
else:
default_val = "pep621"
elif self.project_info.is_rust_cargo:
Expand Down