diff --git a/.github/.codecov.yml b/.github/.codecov.yml new file mode 100644 index 0000000000..85b43f3fef --- /dev/null +++ b/.github/.codecov.yml @@ -0,0 +1,7 @@ +coverage: + status: + project: + default: + # minimum of 97% (real 96%) + target: 97% + threshold: 1% diff --git a/commitizen/__init__.py b/commitizen/__init__.py index 6db9e6e7db..f16def4441 100644 --- a/commitizen/__init__.py +++ b/commitizen/__init__.py @@ -1,7 +1,7 @@ import logging import logging.config -from colorama import init +from colorama import init # type: ignore from commitizen.cz.base import BaseCommitizen diff --git a/commitizen/commands/init.py b/commitizen/commands/init.py index fe6167b7f7..08fdadef77 100644 --- a/commitizen/commands/init.py +++ b/commitizen/commands/init.py @@ -36,7 +36,7 @@ def is_python_poetry(self) -> bool: if not self.has_pyproject: return False with open("pyproject.toml") as f: - return "tool.poetry.version" in f.read() + return "[tool.poetry]" in f.read() @property def is_python(self) -> bool: diff --git a/commitizen/config/json_config.py b/commitizen/config/json_config.py index 34a81a9ef7..29d76040f1 100644 --- a/commitizen/config/json_config.py +++ b/commitizen/config/json_config.py @@ -1,6 +1,7 @@ import json from pathlib import Path from typing import Union +from commitizen.exceptions import InvalidConfigurationError from commitizen.git import smart_open @@ -11,8 +12,8 @@ class JsonConfig(BaseConfig): def __init__(self, *, data: Union[bytes, str], path: Union[Path, str]): super(JsonConfig, self).__init__() self.is_empty_config = False - self._parse_setting(data) self.add_path(path) + self._parse_setting(data) def init_empty_config_content(self): with smart_open(self.path, "a") as json_file: @@ -43,7 +44,11 @@ def _parse_setting(self, data: Union[bytes, str]) -> None: } ``` """ - doc = json.loads(data) + try: + doc = json.loads(data) + except json.JSONDecodeError: + raise InvalidConfigurationError(f"Failed to parse {self.path}") + try: self.settings.update(doc["commitizen"]) except KeyError: diff --git a/docs/README.md b/docs/README.md index c839ddda13..75f46c7b7c 100644 --- a/docs/README.md +++ b/docs/README.md @@ -42,8 +42,6 @@ descriptive commits. [Python](https://www.python.org/downloads/) `3.7+` -[Poetry](https://python-poetry.org/docs/) `1.2.0+` - [Git][gitscm] `1.8.5.2+` ## Installation diff --git a/docs/config.md b/docs/config.md index 3e5734a89a..f93aca60e7 100644 --- a/docs/config.md +++ b/docs/config.md @@ -292,6 +292,13 @@ Commitizen provides some version providers for some well known formats: !!! note The `scm` provider is meant to be used with `setuptools-scm` or any packager `*-scm` plugin. +An example in your `.cz.toml` would look like this: + +```toml +[tool.commitizen] +version_provider = "pep621" +``` + ### Custom version provider You can add you own version provider by extending `VersionProvider` and exposing it on the `commitizen.provider` entrypoint. diff --git a/docs/contributing.md b/docs/contributing.md index c21c7b5e49..21a7ffb39d 100644 --- a/docs/contributing.md +++ b/docs/contributing.md @@ -8,7 +8,7 @@ If you're a first-time contributor, you can check the issues with [good first is ## Install before contributing -1. Install [poetry](https://python-poetry.org/), installation [pages](https://python-poetry.org/docs/#installing-with-the-official-installer) +1. Install [poetry](https://python-poetry.org/) `1.2.0+`, installation [pages](https://python-poetry.org/docs/#installing-with-the-official-installer) 2. Install [gpg](https://gnupg.org), installation [pages](https://gnupg.org/documentation/manuals/gnupg/Installation.html#Installation). For Mac users, you could try [homebrew](https://brew.sh/). ## Before making a pull request diff --git a/docs/tutorials/github_actions.md b/docs/tutorials/github_actions.md index b5d05bb935..3cb92725a5 100644 --- a/docs/tutorials/github_actions.md +++ b/docs/tutorials/github_actions.md @@ -29,7 +29,7 @@ jobs: name: "Bump version and create changelog with commitizen" steps: - name: Check out - uses: actions/checkout@v2 + uses: actions/checkout@v3 with: token: "${{ secrets.PERSONAL_ACCESS_TOKEN }}" fetch-depth: 0 @@ -94,14 +94,21 @@ jobs: deploy: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v1 + - uses: actions/checkout@v3 + with: + fetch-depth: 0 - name: Set up Python - uses: actions/setup-python@v1 + uses: actions/setup-python@v4 with: python-version: "3.x" + - name: Install Poetry + uses: snok/install-poetry@v1 + with: + version: latest + virtualenvs-in-project: true + virtualenvs-create: true - name: Install dependencies run: | - python -m pip install --pre -U poetry poetry --version poetry install - name: Build and publish @@ -112,7 +119,7 @@ jobs: ./scripts/publish ``` -Notice that we are calling a bash script in `./scripts/publish`, you should configure it with your tools (twine, poetry, etc.). Check [commitizen example](https://github.com/commitizen-tools/commitizen/blob/master/scripts/publish) +Notice that we are using poetry, and we are calling a bash script in `./scripts/publish`. You should configure the action, and the publish with your tools (twine, poetry, etc.). Check [commitizen example](https://github.com/commitizen-tools/commitizen/blob/master/scripts/publish) You can also use [pypa/gh-action-pypi-publish](https://github.com/pypa/gh-action-pypi-publish) to publish your package. Push the changes and that's it. diff --git a/docs/tutorials/gitlab_ci.md b/docs/tutorials/gitlab_ci.md index 8c3fd73711..aea7ade99d 100644 --- a/docs/tutorials/gitlab_ci.md +++ b/docs/tutorials/gitlab_ci.md @@ -91,7 +91,7 @@ auto-bump: - git config --global user.email "${CI_EMAIL}" && git config --global user.name "${CI_USERNAME}" - 'exists=`git show-ref refs/heads/master` && if [ -n "$exists" ]; then git branch -D master; fi' - git checkout -b master - - cz bump # execute auto bump and push to master + - cz bump --yes # execute auto bump and push to master - git push origin master:$CI_COMMIT_REF_NAME - TAG=$(head -n 1 VERSION) # get the new software version and save into artifacts - echo "#!/bin/sh" >> variables diff --git a/poetry.lock b/poetry.lock index 1026be8db4..e37d6786ab 100644 --- a/poetry.lock +++ b/poetry.lock @@ -1,4 +1,4 @@ -# This file is automatically @generated by Poetry and should not be changed by hand. +# This file is automatically @generated by Poetry 1.4.0 and should not be changed by hand. [[package]] name = "appnope" @@ -285,14 +285,14 @@ toml = ["tomli"] [[package]] name = "decli" -version = "0.5.2" +version = "0.6.0" description = "Minimal, easy-to-use, declarative cli tool" category = "main" optional = false -python-versions = ">=3.6" +python-versions = ">=3.7" files = [ - {file = "decli-0.5.2-py3-none-any.whl", hash = "sha256:d3207bc02d0169bf6ed74ccca09ce62edca0eb25b0ebf8bf4ae3fb8333e15ca0"}, - {file = "decli-0.5.2.tar.gz", hash = "sha256:f2cde55034a75c819c630c7655a844c612f2598c42c21299160465df6ad463ad"}, + {file = "decli-0.6.0-py3-none-any.whl", hash = "sha256:d5ed1d509f5a6cf765a4d7350f7ffb0be0c1770840cbd38b05fb0aab642645e8"}, + {file = "decli-0.6.0.tar.gz", hash = "sha256:2915a55525ef2b1a0ce88b8ccba62ac22df5b6ff3ed2094448e0f951f08e7ba5"}, ] [[package]] @@ -1598,4 +1598,4 @@ testing = ["big-O", "flake8 (<5)", "jaraco.functools", "jaraco.itertools", "more [metadata] lock-version = "2.0" python-versions = "^3.7" -content-hash = "f85c312b8da45408e78e463496840bcb3d770ee5731a2aada55c56bcae86e547" +content-hash = "4f5717948f57b7d1390ab77b52e038d90b84cba754650c484f5f3ae013cf86e1" diff --git a/pyproject.toml b/pyproject.toml index f27c80ca6a..98574e8a3b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -36,7 +36,7 @@ classifiers = [ [tool.poetry.dependencies] python = "^3.7" questionary = "^1.4.0" -decli = "^0.5.2" +decli = "^0.6.0" colorama = "^0.4.1" termcolor = ">= 1.1, < 3" packaging = ">=19" @@ -140,7 +140,6 @@ convention = "google" [tool.mypy] files = "commitizen" -ignore_missing_imports = true disallow_untyped_decorators = true disallow_subclassing_any = true warn_return_any = true