Skip to content

fix(commands/init): add missing uv provider to "cz init" #1378

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

Merged
merged 2 commits into from
Apr 4, 2025
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 @@
def has_pyproject(self) -> bool:
return os.path.isfile("pyproject.toml")

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

Check warning on line 29 in commitizen/commands/init.py

View check run for this annotation

Codecov / codecov/patch

commitizen/commands/init.py#L29

Added line #L29 was not covered by tests

@property
def has_setup(self) -> bool:
return os.path.isfile("setup.py")
Expand All @@ -32,6 +36,10 @@
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

Check warning on line 41 in commitizen/commands/init.py

View check run for this annotation

Codecov / codecov/patch

commitizen/commands/init.py#L41

Added line #L41 was not covered by tests

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

Check warning on line 248 in commitizen/commands/init.py

View check run for this annotation

Codecov / codecov/patch

commitizen/commands/init.py#L247-L248

Added lines #L247 - L248 were not covered by tests
else:
default_val = "pep621"
elif self.project_info.is_rust_cargo:
Expand Down