From 930c2a7677d5b070a23a3b33ef8ec0b4dc3006b4 Mon Sep 17 00:00:00 2001 From: Wei Lee Date: Sun, 30 Mar 2025 17:50:23 +0800 Subject: [PATCH 1/2] fix(commands/init): add missing uv provider to "cz init" --- commitizen/commands/init.py | 1 + 1 file changed, 1 insertion(+) diff --git a/commitizen/commands/init.py b/commitizen/commands/init.py index e39dfbe29..14ec8067e 100644 --- a/commitizen/commands/init.py +++ b/commitizen/commands/init.py @@ -228,6 +228,7 @@ 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", } From 6c97d555f35dc91b303d6d132eb49cc4f5ce6619 Mon Sep 17 00:00:00 2001 From: Wei Lee Date: Fri, 4 Apr 2025 23:48:55 +0800 Subject: [PATCH 2/2] feat(init): set uv to default value if both pyproject.toml and uv.lock present --- commitizen/commands/init.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/commitizen/commands/init.py b/commitizen/commands/init.py index 14ec8067e..df872ec7e 100644 --- a/commitizen/commands/init.py +++ b/commitizen/commands/init.py @@ -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") @@ -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: @@ -236,6 +244,8 @@ def _ask_version_provider(self) -> str: 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: