From a202e661bacf9643373255965f34bbdb382cb299 Mon Sep 17 00:00:00 2001 From: "Axel H." Date: Sun, 2 Mar 2025 17:35:30 +0100 Subject: [PATCH 1/6] ci(pre-commit): update `pre-commit` hooks to latest version and fix detected errors --- .pre-commit-config.yaml | 6 +++--- commitizen/tags.py | 20 +++++++++++--------- docs/config.md | 19 +++++++++---------- 3 files changed, 23 insertions(+), 22 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 86997bc3a..bb1beaefc 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -13,7 +13,7 @@ repos: - id: check-useless-excludes - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.4.0 + rev: v5.0.0 hooks: - id: check-vcs-permalinks - id: end-of-file-fixer @@ -30,13 +30,13 @@ repos: - id: detect-private-key - repo: https://github.com/asottile/blacken-docs - rev: 1.13.0 + rev: 1.19.1 hooks: - id: blacken-docs additional_dependencies: [ black~=23.11 ] - repo: https://github.com/codespell-project/codespell - rev: v2.2.4 + rev: v2.4.1 hooks: - id: codespell name: Run codespell to check for common misspellings in files diff --git a/commitizen/tags.py b/commitizen/tags.py index 915dd3120..aa11cb7a9 100644 --- a/commitizen/tags.py +++ b/commitizen/tags.py @@ -55,28 +55,30 @@ class TagRules: Example: - ```py + ```python settings = DEFAULT_SETTINGS.clone() - settings.update({ - "tag_format": "v{version}" - "legacy_tag_formats": ["version{version}", "ver{version}"], - "ignored_tag_formats": ["ignored{version}"], - }) + settings.update( + { + "tag_format": "v{version}", + "legacy_tag_formats": ["version{version}", "ver{version}"], + "ignored_tag_formats": ["ignored{version}"], + } + ) rules = TagRules.from_settings(settings) assert rules.is_version_tag("v1.0.0") assert rules.is_version_tag("version1.0.0") assert rules.is_version_tag("ver1.0.0") - assert not rules.is_version_tag("ignored1.0.0", warn=True) # Does not warn - assert not rules.is_version_tag("warn1.0.0", warn=True) # Does warn + assert not rules.is_version_tag("ignored1.0.0", warn=True) # Does not warn + assert not rules.is_version_tag("warn1.0.0", warn=True) # Does warn assert rules.search_version("# My v1.0.0 version").version == "1.0.0" assert rules.extract_version("v1.0.0") == Version("1.0.0") try: assert rules.extract_version("not-a-v1.0.0") except InvalidVersion: - print "Does not match a tag format" + print("Does not match a tag format") ``` """ diff --git a/docs/config.md b/docs/config.md index 3d5324958..d1ae90b29 100644 --- a/docs/config.md +++ b/docs/config.md @@ -352,7 +352,7 @@ Commitizen provides some version providers for some well known formats: | `scm` | Fetch the version from git and does not need to set it back | | `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` `project.version` field and `uv.lock` `pacakge.version` field whose `package.name` field is the same as `pyproject.toml` `project.name` field | +| `uv` | Get and set version from `pyproject.toml` `project.version` field and `uv.lock` `package.version` field whose `package.name` field is the same as `pyproject.toml` `project.name` field | | `cargo` | Get and set version from `Cargo.toml` `project.version` field | | `npm` | Get and set version from `package.json` `version` field, `package-lock.json` `version,packages.''.version` fields if the file exists, and `npm-shrinkwrap.json` `version,packages.''.version` fields if the file exists | | `composer` | Get and set version from `composer.json` `project.version` field | @@ -386,22 +386,21 @@ class MyProvider(VersionProvider): def set_version(self, version: str): self.file.write_text(version) - ``` ```python title="setup.py" from setuptools import setup setup( - name='my-commitizen-provider', - version='0.1.0', - py_modules=['my_provider'], - install_requires=['commitizen'], - entry_points = { - 'commitizen.provider': [ - 'my-provider = my_provider:MyProvider', + name="my-commitizen-provider", + version="0.1.0", + py_modules=["my_provider"], + install_requires=["commitizen"], + entry_points={ + "commitizen.provider": [ + "my-provider = my_provider:MyProvider", ] - } + }, ) ``` From 58eecdccbaf02879dc5672f431485b582c66ffad Mon Sep 17 00:00:00 2001 From: Capi Etheriel Date: Sun, 16 Mar 2025 19:18:22 -0300 Subject: [PATCH 2/6] update precommit example --- docs/getting_started.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/getting_started.md b/docs/getting_started.md index 378b81919..3c6257c36 100644 --- a/docs/getting_started.md +++ b/docs/getting_started.md @@ -94,7 +94,7 @@ repos: hooks: - id: commitizen - id: commitizen-branch - stages: [push] + stages: [pre-push] ``` After the configuration is added, you'll need to run: From 13bc11a9c560bad69c24a08b153b7ad0ca769fff Mon Sep 17 00:00:00 2001 From: Wei Lee Date: Thu, 20 Mar 2025 22:11:40 +0800 Subject: [PATCH 3/6] build(pyproject.toml): fix license metadata --- pyproject.toml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 314ddd925..cedccabb0 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -7,7 +7,7 @@ maintainers = [ { name = "Wei Lee", email = "weilee.rx@gmail.com" }, { name = "Axel H.", email = "noirbizarre@gmail.com" }, ] -license = { text = "LICENSE" } +license = { file = "LICENSE" } readme = "docs/README.md" requires-python = ">=3.9,<4.0" dependencies = [ @@ -42,6 +42,7 @@ classifiers = [ "Programming Language :: Python :: 3.12", "Programming Language :: Python :: 3.13", "Programming Language :: Python :: Implementation :: CPython", + "License :: OSI Approved :: MIT License", ] [project.urls] From 17021fa05ef37e754fd37053c822071c3368b3ca Mon Sep 17 00:00:00 2001 From: Wei Lee Date: Sun, 30 Mar 2025 17:50:23 +0800 Subject: [PATCH 4/6] 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 904173e3193714d2db6a67615bd8ee1132065526 Mon Sep 17 00:00:00 2001 From: Wei Lee Date: Fri, 4 Apr 2025 23:48:55 +0800 Subject: [PATCH 5/6] 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: From e0b1c7743d5ea0bcba82e4ff515ce2caf5e87865 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Fri, 4 Apr 2025 22:07:31 +0000 Subject: [PATCH 6/6] =?UTF-8?q?bump:=20version=204.4.1=20=E2=86=92=204.5.0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .pre-commit-config.yaml | 2 +- CHANGELOG.md | 10 ++++++++++ commitizen/__version__.py | 2 +- pyproject.toml | 4 ++-- 4 files changed, 14 insertions(+), 4 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index bb1beaefc..6c1cbd767 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -48,7 +48,7 @@ repos: - tomli - repo: https://github.com/commitizen-tools/commitizen - rev: v4.4.1 # automatically updated by Commitizen + rev: v4.5.0 # automatically updated by Commitizen hooks: - id: commitizen - id: commitizen-branch diff --git a/CHANGELOG.md b/CHANGELOG.md index 8fc88ad69..6250af20d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,13 @@ +## v4.5.0 (2025-04-04) + +### Feat + +- **init**: set uv to default value if both pyproject.toml and uv.lock present + +### Fix + +- **commands/init**: add missing uv provider to "cz init" + ## v4.4.1 (2025-03-02) ### Fix diff --git a/commitizen/__version__.py b/commitizen/__version__.py index 9905939ff..9faa2c2dd 100644 --- a/commitizen/__version__.py +++ b/commitizen/__version__.py @@ -1 +1 @@ -__version__ = "4.4.1" +__version__ = "4.5.0" diff --git a/pyproject.toml b/pyproject.toml index cedccabb0..009bd13ca 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "commitizen" -version = "4.4.1" +version = "4.5.0" description = "Python commitizen client tool" authors = [{ name = "Santiago Fraire", email = "santiwilly@gmail.com" }] maintainers = [ @@ -88,7 +88,7 @@ build-backend = "poetry.core.masonry.api" [tool.commitizen] -version = "4.4.1" +version = "4.5.0" tag_format = "v$version" version_files = [ "pyproject.toml:version",