Skip to content

Fix/deps #729

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 8 commits into from
May 1, 2023
Merged
Show file tree
Hide file tree
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
7 changes: 7 additions & 0 deletions .github/.codecov.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
coverage:
status:
project:
default:
# minimum of 97% (real 96%)
target: 97%
threshold: 1%
2 changes: 1 addition & 1 deletion commitizen/__init__.py
Original file line number Diff line number Diff line change
@@ -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

Expand Down
2 changes: 1 addition & 1 deletion commitizen/commands/init.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
9 changes: 7 additions & 2 deletions commitizen/config/json_config.py
Original file line number Diff line number Diff line change
@@ -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

Expand All @@ -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:
Expand Down Expand Up @@ -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:
Expand Down
2 changes: 0 additions & 2 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 7 additions & 0 deletions docs/config.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion docs/contributing.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
17 changes: 12 additions & 5 deletions docs/tutorials/github_actions.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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.
2 changes: 1 addition & 1 deletion docs/tutorials/gitlab_ci.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 6 additions & 6 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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
Expand Down