From ae75dd552dd78054310317a4ca5229b83ea9ed4d Mon Sep 17 00:00:00 2001 From: Santiago Fraire Date: Fri, 28 Apr 2023 08:46:20 +0200 Subject: [PATCH 01/28] test: add test for 'additional' types in conventional commits --- tests/test_bump_find_increment.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/tests/test_bump_find_increment.py b/tests/test_bump_find_increment.py index 32a978556c..22cb42c7b6 100644 --- a/tests/test_bump_find_increment.py +++ b/tests/test_bump_find_increment.py @@ -41,6 +41,12 @@ "fix(setup.py): future is now required for every python version", ] +MAJOR_INCREMENTS_EXCLAMATION_OTHER_TYPE_CC = [ + "chore!: drop support for Python 3.9", + "docs(README): motivation", + "fix(setup.py): future is now required for every python version", +] + PATCH_INCREMENTS_SVE = ["readme motivation PATCH", "fix setup.py PATCH"] MINOR_INCREMENTS_SVE = [ @@ -67,6 +73,7 @@ (MINOR_INCREMENTS_CC, "MINOR"), (MAJOR_INCREMENTS_BREAKING_CHANGE_CC, "MAJOR"), (MAJOR_INCREMENTS_BREAKING_CHANGE_ALT_CC, "MAJOR"), + (MAJOR_INCREMENTS_EXCLAMATION_OTHER_TYPE_CC, "MAJOR"), (MAJOR_INCREMENTS_EXCLAMATION_CC, "MAJOR"), (NONE_INCREMENT_CC, None), ), From e37c0a90ef9dab0ced7d922fd9a26b89b50ba3fe Mon Sep 17 00:00:00 2001 From: Santiago Fraire Date: Fri, 28 Apr 2023 09:08:38 +0200 Subject: [PATCH 02/28] fix(bump): breaking changes on additional types for conventional commits --- commitizen/defaults.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/commitizen/defaults.py b/commitizen/defaults.py index fb117547f8..c8e12780ca 100644 --- a/commitizen/defaults.py +++ b/commitizen/defaults.py @@ -88,7 +88,7 @@ class Settings(TypedDict, total=False): MINOR = "MINOR" PATCH = "PATCH" -bump_pattern = r"^(BREAKING[\-\ ]CHANGE|feat|fix|refactor|perf)(\(.+\))?(!)?" +bump_pattern = r"^(((BREAKING[\-\ ]CHANGE|feat|fix|refactor|perf)(\(.+\))?(!)?)|\w+!)" bump_map = OrderedDict( ( (r"^.+!$", MAJOR), From 87a5c98d7b3e882bee74cde85b83f47f52f756f1 Mon Sep 17 00:00:00 2001 From: Santiago Fraire Date: Fri, 28 Apr 2023 09:27:22 +0200 Subject: [PATCH 03/28] test: add test for 'additional' types in changelog --- tests/commands/test_changelog_command.py | 12 ++++++++++++ ...eaking_change_content_v1_with_exclamation_mark.md | 5 +++++ 2 files changed, 17 insertions(+) create mode 100644 tests/commands/test_changelog_command/test_breaking_change_content_v1_with_exclamation_mark.md diff --git a/tests/commands/test_changelog_command.py b/tests/commands/test_changelog_command.py index bdc384c3ca..ceab831269 100644 --- a/tests/commands/test_changelog_command.py +++ b/tests/commands/test_changelog_command.py @@ -515,6 +515,18 @@ def test_breaking_change_content_v1_multiline( file_regression.check(out, extension=".md") +@pytest.mark.usefixtures("tmp_commitizen_project") +def test_breaking_change_content_v1_with_exclamation_mark(mocker: MockFixture, capsys, file_regression): + commit_message = "chore!: drop support for py36" + create_file_and_commit(commit_message) + testargs = ["cz", "changelog", "--dry-run"] + mocker.patch.object(sys, "argv", testargs) + with pytest.raises(DryRunExit): + cli.main() + out, _ = capsys.readouterr() + + file_regression.check(out, extension=".md") + @pytest.mark.usefixtures("tmp_commitizen_project") def test_changelog_config_flag_increment( mocker: MockFixture, changelog_path, config_path, file_regression diff --git a/tests/commands/test_changelog_command/test_breaking_change_content_v1_with_exclamation_mark.md b/tests/commands/test_changelog_command/test_breaking_change_content_v1_with_exclamation_mark.md new file mode 100644 index 0000000000..d12d780dab --- /dev/null +++ b/tests/commands/test_changelog_command/test_breaking_change_content_v1_with_exclamation_mark.md @@ -0,0 +1,5 @@ +## Unreleased + + +- drop support for py36 + From 8bfc98dffe221d0598b55272bc9a402cf14add94 Mon Sep 17 00:00:00 2001 From: Santiago Fraire Date: Fri, 28 Apr 2023 09:28:09 +0200 Subject: [PATCH 04/28] fix(changelog): breaking change on additional types for conventional commits --- commitizen/defaults.py | 2 +- tests/commands/test_changelog_command.py | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/commitizen/defaults.py b/commitizen/defaults.py index c8e12780ca..4948ade45f 100644 --- a/commitizen/defaults.py +++ b/commitizen/defaults.py @@ -112,5 +112,5 @@ class Settings(TypedDict, total=False): change_type_order = ["BREAKING CHANGE", "Feat", "Fix", "Refactor", "Perf"] bump_message = "bump: version $current_version → $new_version" -commit_parser = r"^(?Pfeat|fix|refactor|perf|BREAKING CHANGE)(?:\((?P[^()\r\n]*)\)|\()?(?P!)?:\s(?P.*)?" # noqa +commit_parser = r"^((?Pfeat|fix|refactor|perf|BREAKING CHANGE)(?:\((?P[^()\r\n]*)\)|\()?(?P!)?|\w+!):\s(?P.*)?" # noqa version_parser = r"(?P([0-9]+)\.([0-9]+)\.([0-9]+)(?:-([0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*))?(?:\+[0-9A-Za-z-]+)?(\w+)?)" diff --git a/tests/commands/test_changelog_command.py b/tests/commands/test_changelog_command.py index ceab831269..e0931ee166 100644 --- a/tests/commands/test_changelog_command.py +++ b/tests/commands/test_changelog_command.py @@ -516,7 +516,9 @@ def test_breaking_change_content_v1_multiline( @pytest.mark.usefixtures("tmp_commitizen_project") -def test_breaking_change_content_v1_with_exclamation_mark(mocker: MockFixture, capsys, file_regression): +def test_breaking_change_content_v1_with_exclamation_mark( + mocker: MockFixture, capsys, file_regression +): commit_message = "chore!: drop support for py36" create_file_and_commit(commit_message) testargs = ["cz", "changelog", "--dry-run"] @@ -527,6 +529,7 @@ def test_breaking_change_content_v1_with_exclamation_mark(mocker: MockFixture, c file_regression.check(out, extension=".md") + @pytest.mark.usefixtures("tmp_commitizen_project") def test_changelog_config_flag_increment( mocker: MockFixture, changelog_path, config_path, file_regression From 93874fcb2df2830cbed5d905d1c707f0dba1342b Mon Sep 17 00:00:00 2001 From: Santiago Fraire Date: Fri, 28 Apr 2023 12:00:44 +0200 Subject: [PATCH 05/28] fix: bump decli which is type hinted Closes #153 --- commitizen/__init__.py | 2 +- poetry.lock | 12 ++++++------ pyproject.toml | 3 +-- 3 files changed, 8 insertions(+), 9 deletions(-) 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/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 From 51f9d9744cfc78c1374da4fb1529048b5da09ba6 Mon Sep 17 00:00:00 2001 From: Santiago Fraire Date: Fri, 28 Apr 2023 12:02:17 +0200 Subject: [PATCH 06/28] docs: move poetry req to contributing --- docs/README.md | 2 -- docs/contributing.md | 2 +- 2 files changed, 1 insertion(+), 3 deletions(-) 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/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 From b0d87783e1f16fa6e33e54d460d37999b1b21ae1 Mon Sep 17 00:00:00 2001 From: Santiago Fraire Date: Fri, 28 Apr 2023 12:03:08 +0200 Subject: [PATCH 07/28] fix(init): poetry detection --- commitizen/commands/init.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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: From b7b96f60b1aded8b74e9ee27ca2955b62bd401b6 Mon Sep 17 00:00:00 2001 From: Santiago Fraire Date: Fri, 28 Apr 2023 12:31:15 +0200 Subject: [PATCH 08/28] fix: improve errors message when empty .cz.json found Closes #576 --- commitizen/config/json_config.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) 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: From c20cb5cc76aba40700c70bcfa945c5c7c99b5d35 Mon Sep 17 00:00:00 2001 From: Santiago Fraire Date: Fri, 28 Apr 2023 14:13:57 +0200 Subject: [PATCH 09/28] test(bump): a longer word is used matching a type in commit message --- tests/test_bump_find_increment.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/tests/test_bump_find_increment.py b/tests/test_bump_find_increment.py index 22cb42c7b6..d4eb96d8b8 100644 --- a/tests/test_bump_find_increment.py +++ b/tests/test_bump_find_increment.py @@ -8,7 +8,12 @@ from commitizen.cz.conventional_commits import ConventionalCommitsCz from commitizen.git import GitCommit -NONE_INCREMENT_CC = ["docs(README): motivation", "ci: added travis"] +NONE_INCREMENT_CC = [ + "docs(README): motivation", + "ci: added travis", + "performance. Remove or disable the reimplemented linters", + "refactor that how this line starts", +] PATCH_INCREMENTS_CC = [ "fix(setup.py): future is now required for every python version", @@ -19,6 +24,8 @@ "feat(cli): added version", "docs(README): motivation", "fix(setup.py): future is now required for every python version", + "perf: app is much faster", + "refactor: app is much faster", ] MAJOR_INCREMENTS_BREAKING_CHANGE_CC = [ From 92115055da9456f6e227aab3fc77f198059f3d1e Mon Sep 17 00:00:00 2001 From: Santiago Fraire Date: Fri, 28 Apr 2023 14:14:39 +0200 Subject: [PATCH 10/28] fix(bump): better match for change_type when finding increment Closes #695 --- commitizen/bump.py | 7 +++---- commitizen/defaults.py | 2 +- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/commitizen/bump.py b/commitizen/bump.py index c405414e87..ed410bbcc1 100644 --- a/commitizen/bump.py +++ b/commitizen/bump.py @@ -23,7 +23,6 @@ def find_increment( commits: List[GitCommit], regex: str, increments_map: Union[dict, OrderedDict] ) -> Optional[str]: - if isinstance(increments_map, dict): increments_map = OrderedDict(increments_map) @@ -35,8 +34,9 @@ def find_increment( for commit in commits: for message in commit.message.split("\n"): result = select_pattern.search(message) + if result: - found_keyword = result.group(0) + found_keyword = result.group(1) new_increment = None for match_pattern in increments_map.keys(): if re.match(match_pattern, found_keyword): @@ -44,7 +44,7 @@ def find_increment( break if increment == "MAJOR": - continue + break elif increment == "MINOR" and new_increment == "MAJOR": increment = new_increment elif increment == "PATCH" or increment is None: @@ -103,7 +103,6 @@ def semver_generator(current_version: str, increment: str = None) -> str: # so it doesn't matter the increment. # Example: 1.0.0a0 with PATCH/MINOR -> 1.0.0 if not version.is_prerelease: - if increment == MAJOR: increments_version[MAJOR] += 1 increments_version[MINOR] = 0 diff --git a/commitizen/defaults.py b/commitizen/defaults.py index 4948ade45f..a7c285edba 100644 --- a/commitizen/defaults.py +++ b/commitizen/defaults.py @@ -88,7 +88,7 @@ class Settings(TypedDict, total=False): MINOR = "MINOR" PATCH = "PATCH" -bump_pattern = r"^(((BREAKING[\-\ ]CHANGE|feat|fix|refactor|perf)(\(.+\))?(!)?)|\w+!)" +bump_pattern = r"^(((BREAKING[\-\ ]CHANGE|feat|fix|refactor|perf)(\(.+\))?(!)?)|\w+!):" bump_map = OrderedDict( ( (r"^.+!$", MAJOR), From 376427c9f219dddbd68061d40c76a8f98c1d38bf Mon Sep 17 00:00:00 2001 From: Santiago Fraire Date: Fri, 28 Apr 2023 14:26:52 +0200 Subject: [PATCH 11/28] test: add exclamation mark test Closes #682 --- tests/commands/test_changelog_command.py | 15 +++++++++++++++ ...hange_content_v1_with_exclamation_mark_feat.md | 6 ++++++ tests/test_bump_find_increment.py | 5 +++++ 3 files changed, 26 insertions(+) create mode 100644 tests/commands/test_changelog_command/test_breaking_change_content_v1_with_exclamation_mark_feat.md diff --git a/tests/commands/test_changelog_command.py b/tests/commands/test_changelog_command.py index e0931ee166..bb63720839 100644 --- a/tests/commands/test_changelog_command.py +++ b/tests/commands/test_changelog_command.py @@ -530,6 +530,21 @@ def test_breaking_change_content_v1_with_exclamation_mark( file_regression.check(out, extension=".md") +@pytest.mark.usefixtures("tmp_commitizen_project") +def test_breaking_change_content_v1_with_exclamation_mark_feat( + mocker: MockFixture, capsys, file_regression +): + commit_message = "feat(pipeline)!: some text with breaking change" + create_file_and_commit(commit_message) + testargs = ["cz", "changelog", "--dry-run"] + mocker.patch.object(sys, "argv", testargs) + with pytest.raises(DryRunExit): + cli.main() + out, _ = capsys.readouterr() + + file_regression.check(out, extension=".md") + + @pytest.mark.usefixtures("tmp_commitizen_project") def test_changelog_config_flag_increment( mocker: MockFixture, changelog_path, config_path, file_regression diff --git a/tests/commands/test_changelog_command/test_breaking_change_content_v1_with_exclamation_mark_feat.md b/tests/commands/test_changelog_command/test_breaking_change_content_v1_with_exclamation_mark_feat.md new file mode 100644 index 0000000000..84c23687c4 --- /dev/null +++ b/tests/commands/test_changelog_command/test_breaking_change_content_v1_with_exclamation_mark_feat.md @@ -0,0 +1,6 @@ +## Unreleased + +### Feat + +- **pipeline**: some text with breaking change + diff --git a/tests/test_bump_find_increment.py b/tests/test_bump_find_increment.py index d4eb96d8b8..337cf17e7a 100644 --- a/tests/test_bump_find_increment.py +++ b/tests/test_bump_find_increment.py @@ -48,6 +48,10 @@ "fix(setup.py): future is now required for every python version", ] +MAJOR_INCREMENTS_EXCLAMATION_CC_SAMPLE_2 = [ + "feat(pipeline)!: some text with breaking change" +] + MAJOR_INCREMENTS_EXCLAMATION_OTHER_TYPE_CC = [ "chore!: drop support for Python 3.9", "docs(README): motivation", @@ -82,6 +86,7 @@ (MAJOR_INCREMENTS_BREAKING_CHANGE_ALT_CC, "MAJOR"), (MAJOR_INCREMENTS_EXCLAMATION_OTHER_TYPE_CC, "MAJOR"), (MAJOR_INCREMENTS_EXCLAMATION_CC, "MAJOR"), + (MAJOR_INCREMENTS_EXCLAMATION_CC_SAMPLE_2, "MAJOR"), (NONE_INCREMENT_CC, None), ), ) From fbd2e21a7f44583af1abe9b43376d0755c277af3 Mon Sep 17 00:00:00 2001 From: Santiago Fraire Date: Fri, 28 Apr 2023 14:52:40 +0200 Subject: [PATCH 12/28] docs: improve gitlab tutorial Closes #610 --- docs/tutorials/gitlab_ci.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 From f87a3af03ccd3a029267ad105a9ae8f0cad3e0e3 Mon Sep 17 00:00:00 2001 From: Santiago Fraire Date: Fri, 28 Apr 2023 15:10:00 +0200 Subject: [PATCH 13/28] docs: improve github action tutorial --- docs/tutorials/github_actions.md | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) 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. From 6e104cad351a8f145a7214b38387d401eca2f94d Mon Sep 17 00:00:00 2001 From: Santiago Fraire Date: Fri, 28 Apr 2023 15:27:42 +0200 Subject: [PATCH 14/28] docs(config): show config sample for version provider --- docs/config.md | 7 +++++++ 1 file changed, 7 insertions(+) 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. From ff56b4e6928c56f08875042d21f859645bf67e3e Mon Sep 17 00:00:00 2001 From: crai0 Date: Fri, 28 Apr 2023 17:52:49 +0200 Subject: [PATCH 15/28] feat(commit): add --write-message-to-file option --- commitizen/cli.py | 7 ++++++- commitizen/commands/commit.py | 13 +++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/commitizen/cli.py b/commitizen/cli.py index b59c257db3..f1f269a621 100644 --- a/commitizen/cli.py +++ b/commitizen/cli.py @@ -62,10 +62,15 @@ "action": "store_true", "help": "show output to stdout, no commit, no modified files", }, + { + "name": "--write-message-to-file", + "metavar": "FILE_PATH", + "help": "write message to file before commiting (can be combined with --dry-run)", + }, { "name": ["-s", "--signoff"], "action": "store_true", - "help": "Sign off the commit", + "help": "sign off the commit", }, ], }, diff --git a/commitizen/commands/commit.py b/commitizen/commands/commit.py index 13e61abe6d..379f80ba1b 100644 --- a/commitizen/commands/commit.py +++ b/commitizen/commands/commit.py @@ -14,6 +14,7 @@ NoAnswersError, NoCommitBackupError, NotAGitProjectError, + NotAllowed, NothingToCommitError, ) from commitizen.git import smart_open @@ -63,10 +64,18 @@ def prompt_commit_questions(self) -> str: def __call__(self): dry_run: bool = self.arguments.get("dry_run") + write_message_to_file = self.arguments.get("write_message_to_file") if git.is_staging_clean() and not dry_run: raise NothingToCommitError("No files added to staging!") + if write_message_to_file is not None: + if not isinstance(write_message_to_file, str): + raise NotAllowed( + "Commit message file name is broken.\n" + "Check the flag `--write-message-to-file` in the terminal" + ) + retry: bool = self.arguments.get("retry") if retry: @@ -76,6 +85,10 @@ def __call__(self): out.info(f"\n{m}\n") + if write_message_to_file: + with smart_open(write_message_to_file, "w") as file: + file.write(m) + if dry_run: raise DryRunExit() From af8e276eeceed8868a43a62fbffe87dc96444525 Mon Sep 17 00:00:00 2001 From: crai0 Date: Fri, 28 Apr 2023 17:53:39 +0200 Subject: [PATCH 16/28] test(commit): add test for --write-message-to-file option --- tests/commands/test_commit_command.py | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/tests/commands/test_commit_command.py b/tests/commands/test_commit_command.py index dd62fafe85..089132b839 100644 --- a/tests/commands/test_commit_command.py +++ b/tests/commands/test_commit_command.py @@ -109,6 +109,32 @@ def test_commit_command_with_dry_run_option(config, mocker: MockFixture): commit_cmd() +@pytest.mark.usefixtures("staging_is_clean") +def test_commit_command_with_write_message_to_file_option( + config, tmp_path, mocker: MockFixture +): + tmp_file = tmp_path / "message" + + prompt_mock = mocker.patch("questionary.prompt") + prompt_mock.return_value = { + "prefix": "feat", + "subject": "user created", + "scope": "", + "is_breaking_change": False, + "body": "", + "footer": "", + } + + commit_mock = mocker.patch("commitizen.git.commit") + commit_mock.return_value = cmd.Command("success", "", b"", b"", 0) + success_mock = mocker.patch("commitizen.out.success") + + commands.Commit(config, {"write_message_to_file": str(tmp_file)})() + success_mock.assert_called_once() + assert tmp_file.exists() + assert tmp_file.read_text() == "feat: user created" + + @pytest.mark.usefixtures("staging_is_clean") def test_commit_command_with_signoff_option(config, mocker: MockFixture): prompt_mock = mocker.patch("questionary.prompt") From a2d0cb897e998ab2768c8b57e4c3a47d3d67de9d Mon Sep 17 00:00:00 2001 From: crai0 Date: Fri, 28 Apr 2023 17:58:01 +0200 Subject: [PATCH 17/28] docs(commit): document --write-message-to-file option --- docs/commit.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/docs/commit.md b/docs/commit.md index fb3fdd65ac..36ab328919 100644 --- a/docs/commit.md +++ b/docs/commit.md @@ -6,6 +6,10 @@ In your terminal run `cz commit` or the shortcut `cz c` to generate a guided git A commit can be signed off using `cz commit --signoff` or the shortcut `cz commit -s`. +You can run `cz commit --write-message-to-file COMMIT_MSG_FILE` to additionally save the +generated message to a file. This can be combined with the `--dry-run` flag to only +write the message to a file and not modify files and create a commit. + !!! note To maintain platform compatibility, the `commit` command disable ANSI escaping in its output. In particular pre-commit hooks coloring will be deactivated as discussed in [commitizen-tools/commitizen#417](https://github.com/commitizen-tools/commitizen/issues/417). From dc0c86fe3ab295a140aaa4c8126597e5e7c6751a Mon Sep 17 00:00:00 2001 From: crai0 Date: Fri, 28 Apr 2023 18:01:14 +0200 Subject: [PATCH 18/28] docs(tutorials): add tutorial for automatically preparing commit message --- docs/tutorials/auto_prepare_commit_message.md | 27 +++++++++++++++++++ mkdocs.yml | 1 + 2 files changed, 28 insertions(+) create mode 100644 docs/tutorials/auto_prepare_commit_message.md diff --git a/docs/tutorials/auto_prepare_commit_message.md b/docs/tutorials/auto_prepare_commit_message.md new file mode 100644 index 0000000000..91c8817f09 --- /dev/null +++ b/docs/tutorials/auto_prepare_commit_message.md @@ -0,0 +1,27 @@ +# Automatically prepare message before commit + +## About + +To automatically prepare a commit message prior to committing, you can use a [Git hook](https://git-scm.com/book/en/v2/Customizing-Git-Git-Hooks). + +## How to + +- Step 1: Create a new [`prepare-commit-msg`][prepare-commit-msg-docs] Git hook by running the following commands from the root of the Git repository: + +```sh +cd .git/hooks +touch prepare-commit-msg +chmod +x prepare-commit-msg +``` + +- Step 2: Edit the newly created file and add the following content: + +```sh +#!/bin/sh +COMMIT_MSG_FILE=$1 +exec < /dev/tty && cz commit --dry-run --write-message-to-file $COMMIT_MSG_FILE || true +``` + +See the Git hooks documentation on [`prepare-commit-msg` hooks][prepare-commit-msg-docs] for details on how this works. + +[prepare-commit-msg-docs]: https://git-scm.com/docs/githooks#_prepare_commit_msg diff --git a/mkdocs.yml b/mkdocs.yml index da71e30abe..57cf6af46b 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -43,6 +43,7 @@ nav: - Tutorials: - Writing commits: "tutorials/writing_commits.md" - Auto check commits: "tutorials/auto_check.md" + - Auto prepare commit message: "tutorials/auto_prepare_commit_message.md" - GitLab CI: "tutorials/gitlab_ci.md" - Github Actions: "tutorials/github_actions.md" - Jenkins pipeline: "tutorials/jenkins_pipeline.md" From cd93206f37c38dd4392cb8d7589f84d31db67836 Mon Sep 17 00:00:00 2001 From: crai0 Date: Fri, 28 Apr 2023 18:58:20 +0200 Subject: [PATCH 19/28] test(commit): add negative test cases for --write-message-to-file option --- tests/commands/test_commit_command.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/tests/commands/test_commit_command.py b/tests/commands/test_commit_command.py index 089132b839..b116fd9d45 100644 --- a/tests/commands/test_commit_command.py +++ b/tests/commands/test_commit_command.py @@ -12,6 +12,7 @@ NoAnswersError, NoCommitBackupError, NotAGitProjectError, + NotAllowed, NothingToCommitError, ) @@ -135,6 +136,27 @@ def test_commit_command_with_write_message_to_file_option( assert tmp_file.read_text() == "feat: user created" +@pytest.mark.usefixtures("staging_is_clean") +@pytest.mark.parametrize("message_file", [True, False, 0, 1]) +def test_commit_command_with_invalid_write_message_to_file_option( + config, message_file, mocker: MockFixture +): + prompt_mock = mocker.patch("questionary.prompt") + prompt_mock.return_value = { + "prefix": "feat", + "subject": "user created", + "scope": "", + "is_breaking_change": False, + "body": "", + "footer": "", + } + + with pytest.raises(NotAllowed): + print(isinstance(message_file, str)) + commit_cmd = commands.Commit(config, {"write_message_to_file": message_file}) + commit_cmd() + + @pytest.mark.usefixtures("staging_is_clean") def test_commit_command_with_signoff_option(config, mocker: MockFixture): prompt_mock = mocker.patch("questionary.prompt") From 14fac5b12581f799a8b122b6e6f6830fc8c301a1 Mon Sep 17 00:00:00 2001 From: crai0 Date: Sat, 29 Apr 2023 07:33:15 +0200 Subject: [PATCH 20/28] docs(commit): link to prepare-commit-msg hook tutorial --- docs/commit.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/docs/commit.md b/docs/commit.md index 36ab328919..2d50b111ca 100644 --- a/docs/commit.md +++ b/docs/commit.md @@ -8,7 +8,8 @@ A commit can be signed off using `cz commit --signoff` or the shortcut `cz commi You can run `cz commit --write-message-to-file COMMIT_MSG_FILE` to additionally save the generated message to a file. This can be combined with the `--dry-run` flag to only -write the message to a file and not modify files and create a commit. +write the message to a file and not modify files and create a commit. A possible use +case for this is to [automatically prepare a commit message](./tutorials/auto_prepare_commit_message.md). !!! note To maintain platform compatibility, the `commit` command disable ANSI escaping in its output. From ec52a23f50c11d00e20258fdc573836754735250 Mon Sep 17 00:00:00 2001 From: Santiago Fraire Date: Sat, 29 Apr 2023 07:35:37 +0200 Subject: [PATCH 21/28] ci: add codecov minimum --- .github/.codecov.yml | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 .github/.codecov.yml 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% From 4e280758acf6e2e2c8e01831d475a538e7e99d0b Mon Sep 17 00:00:00 2001 From: crai0 Date: Sat, 29 Apr 2023 08:54:54 +0200 Subject: [PATCH 22/28] docs(prepare-commit-msg): add additional information to tutorial --- docs/tutorials/auto_prepare_commit_message.md | 20 ++++++++++++++++++- hooks/prepare-commit-msg.sh | 3 +++ 2 files changed, 22 insertions(+), 1 deletion(-) create mode 100755 hooks/prepare-commit-msg.sh diff --git a/docs/tutorials/auto_prepare_commit_message.md b/docs/tutorials/auto_prepare_commit_message.md index 91c8817f09..1a1a1c40b5 100644 --- a/docs/tutorials/auto_prepare_commit_message.md +++ b/docs/tutorials/auto_prepare_commit_message.md @@ -2,7 +2,20 @@ ## About -To automatically prepare a commit message prior to committing, you can use a [Git hook](https://git-scm.com/book/en/v2/Customizing-Git-Git-Hooks). +It can be desirable to use commitizen for all types of commits (i.e. regular, merge, +squash) so that the complete git history adheres to the commit message convention +without ever having to call `cz commit` manually. + +To automatically prepare a commit message prior to committing, you can +use a [Git hook](prepare-commit-msg-docs): + +> The [prepare-commit-msg] hook is invoked by git-commit right after preparing the +> default log message, and before the editor is started. + +This allows for enforcing the usage of commitizen so that whenever a commit is about to +be created, commitizen is used for creating the commit message. Running `git commit` or +`git commit -m "..."` for example, would trigger commitizen and use the generated commit +message for the commit. ## How to @@ -25,3 +38,8 @@ exec < /dev/tty && cz commit --dry-run --write-message-to-file $COMMIT_MSG_FILE See the Git hooks documentation on [`prepare-commit-msg` hooks][prepare-commit-msg-docs] for details on how this works. [prepare-commit-msg-docs]: https://git-scm.com/docs/githooks#_prepare_commit_msg + +## Drawbacks + +If additional hooks are used (e.g. pre-commit) that prevent a commit from being created, +the message has to be created from scratch when commiting again. diff --git a/hooks/prepare-commit-msg.sh b/hooks/prepare-commit-msg.sh new file mode 100755 index 0000000000..1561164fed --- /dev/null +++ b/hooks/prepare-commit-msg.sh @@ -0,0 +1,3 @@ +#!/bin/sh +COMMIT_MSG_FILE=$1 +exec < /dev/tty && cz commit --dry-run --write-message-to-file $COMMIT_MSG_FILE || true From ea3ecce7ab3e06d5a30c085e5e3aa9e6c286e68e Mon Sep 17 00:00:00 2001 From: crai0 Date: Sun, 30 Apr 2023 13:44:18 +0200 Subject: [PATCH 23/28] refactor(commit): change type of write_message_to_file to path --- commitizen/cli.py | 2 ++ commitizen/commands/commit.py | 8 ++------ hooks/prepare-commit-msg.sh | 3 --- 3 files changed, 4 insertions(+), 9 deletions(-) delete mode 100755 hooks/prepare-commit-msg.sh diff --git a/commitizen/cli.py b/commitizen/cli.py index f1f269a621..ed89b5675a 100644 --- a/commitizen/cli.py +++ b/commitizen/cli.py @@ -1,6 +1,7 @@ import argparse import logging import sys +from pathlib import Path from functools import partial from types import TracebackType from typing import List @@ -64,6 +65,7 @@ }, { "name": "--write-message-to-file", + "type": Path, "metavar": "FILE_PATH", "help": "write message to file before commiting (can be combined with --dry-run)", }, diff --git a/commitizen/commands/commit.py b/commitizen/commands/commit.py index 379f80ba1b..4d9da5c3fa 100644 --- a/commitizen/commands/commit.py +++ b/commitizen/commands/commit.py @@ -69,12 +69,8 @@ def __call__(self): if git.is_staging_clean() and not dry_run: raise NothingToCommitError("No files added to staging!") - if write_message_to_file is not None: - if not isinstance(write_message_to_file, str): - raise NotAllowed( - "Commit message file name is broken.\n" - "Check the flag `--write-message-to-file` in the terminal" - ) + if write_message_to_file is not None and write_message_to_file.is_dir(): + raise NotAllowed(f"{write_message_to_file} is a directory") retry: bool = self.arguments.get("retry") diff --git a/hooks/prepare-commit-msg.sh b/hooks/prepare-commit-msg.sh deleted file mode 100755 index 1561164fed..0000000000 --- a/hooks/prepare-commit-msg.sh +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/sh -COMMIT_MSG_FILE=$1 -exec < /dev/tty && cz commit --dry-run --write-message-to-file $COMMIT_MSG_FILE || true From ab42fd4e42ef01f99196987f89cc029378e8bccc Mon Sep 17 00:00:00 2001 From: crai0 Date: Sat, 29 Apr 2023 11:18:15 +0200 Subject: [PATCH 24/28] test(commit): pass path for write_message_to_file --- tests/commands/test_commit_command.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/tests/commands/test_commit_command.py b/tests/commands/test_commit_command.py index b116fd9d45..b45ac3a552 100644 --- a/tests/commands/test_commit_command.py +++ b/tests/commands/test_commit_command.py @@ -130,16 +130,15 @@ def test_commit_command_with_write_message_to_file_option( commit_mock.return_value = cmd.Command("success", "", b"", b"", 0) success_mock = mocker.patch("commitizen.out.success") - commands.Commit(config, {"write_message_to_file": str(tmp_file)})() + commands.Commit(config, {"write_message_to_file": tmp_file})() success_mock.assert_called_once() assert tmp_file.exists() assert tmp_file.read_text() == "feat: user created" @pytest.mark.usefixtures("staging_is_clean") -@pytest.mark.parametrize("message_file", [True, False, 0, 1]) def test_commit_command_with_invalid_write_message_to_file_option( - config, message_file, mocker: MockFixture + config, tmp_path, mocker: MockFixture ): prompt_mock = mocker.patch("questionary.prompt") prompt_mock.return_value = { @@ -152,8 +151,7 @@ def test_commit_command_with_invalid_write_message_to_file_option( } with pytest.raises(NotAllowed): - print(isinstance(message_file, str)) - commit_cmd = commands.Commit(config, {"write_message_to_file": message_file}) + commit_cmd = commands.Commit(config, {"write_message_to_file": tmp_path}) commit_cmd() From 5b4f94469da93463a7357aea6678525068cf313d Mon Sep 17 00:00:00 2001 From: crai0 Date: Sun, 30 Apr 2023 17:49:14 +0200 Subject: [PATCH 25/28] feat(hooks): add prepare-commit-msg and post-commit hooks --- hooks/post-commit.py | 18 ++++++++++ hooks/prepare-commit-msg.py | 65 +++++++++++++++++++++++++++++++++++++ 2 files changed, 83 insertions(+) create mode 100755 hooks/post-commit.py create mode 100755 hooks/prepare-commit-msg.py diff --git a/hooks/post-commit.py b/hooks/post-commit.py new file mode 100755 index 0000000000..c2faebb738 --- /dev/null +++ b/hooks/post-commit.py @@ -0,0 +1,18 @@ +#!/usr/bin/env python +import os +import tempfile +from pathlib import Path + + +def post_commit(): + backup_file = Path( + tempfile.gettempdir(), f"cz.commit{os.environ.get('USER', '')}.backup" + ) + + # remove backup file if it exists + if backup_file.is_file(): + backup_file.unlink() + + +if __name__ == "__main__": + exit(post_commit()) diff --git a/hooks/prepare-commit-msg.py b/hooks/prepare-commit-msg.py new file mode 100755 index 0000000000..58beb3a0f8 --- /dev/null +++ b/hooks/prepare-commit-msg.py @@ -0,0 +1,65 @@ +#!/usr/bin/env python +import os +import shutil +import subprocess +import sys +import tempfile +from pathlib import Path +from subprocess import CalledProcessError + + +def prepare_commit_msg(commit_msg_file: Path) -> int: + # check that commitizen is installed + if shutil.which("cz") is None: + print("commitizen is not installed!") + return 0 + + # check if the commit message needs to be generated using commitizen + if ( + subprocess.run( + [ + "cz", + "check", + "--commit-msg-file", + commit_msg_file, + ], + capture_output=True, + ).returncode + != 0 + ): + backup_file = Path( + tempfile.gettempdir(), f"cz.commit{os.environ.get('USER', '')}.backup" + ) + + if backup_file.is_file(): + # confirm if commit message from backup file should be reused + answer = input("retry with previous message? [y/N]: ") + if answer.lower() == "y": + shutil.copyfile(backup_file, commit_msg_file) + return 0 + + # use commitizen to generate the commit message + try: + subprocess.run( + [ + "cz", + "commit", + "--dry-run", + "--write-message-to-file", + commit_msg_file, + ], + stdin=sys.stdin, + stdout=sys.stdout, + ).check_returncode() + except CalledProcessError as error: + return error.returncode + + # write message to backup file + shutil.copyfile(commit_msg_file, backup_file) + + +if __name__ == "__main__": + # make hook interactive by attaching /dev/tty to stdin + with open("/dev/tty") as tty: + sys.stdin = tty + exit(prepare_commit_msg(sys.argv[1])) From f04a719746594e9f4906dd44cc75f773fccd4e1f Mon Sep 17 00:00:00 2001 From: crai0 Date: Sun, 30 Apr 2023 17:49:41 +0200 Subject: [PATCH 26/28] docs(tutorials): add installation guide and feature overview for hooks --- docs/tutorials/auto_prepare_commit_message.md | 51 ++++++++++--------- 1 file changed, 26 insertions(+), 25 deletions(-) diff --git a/docs/tutorials/auto_prepare_commit_message.md b/docs/tutorials/auto_prepare_commit_message.md index 1a1a1c40b5..8def5f2e28 100644 --- a/docs/tutorials/auto_prepare_commit_message.md +++ b/docs/tutorials/auto_prepare_commit_message.md @@ -4,42 +4,43 @@ It can be desirable to use commitizen for all types of commits (i.e. regular, merge, squash) so that the complete git history adheres to the commit message convention -without ever having to call `cz commit` manually. +without ever having to call `cz commit`. To automatically prepare a commit message prior to committing, you can -use a [Git hook](prepare-commit-msg-docs): +use a [prepare-commit-msg Git hook](prepare-commit-msg-docs): -> The [prepare-commit-msg] hook is invoked by git-commit right after preparing the +> This hook is invoked by git-commit right after preparing the > default log message, and before the editor is started. -This allows for enforcing the usage of commitizen so that whenever a commit is about to -be created, commitizen is used for creating the commit message. Running `git commit` or -`git commit -m "..."` for example, would trigger commitizen and use the generated commit -message for the commit. +To automatically perform arbitrary cleanup steps after a succesful commit you can use a +[post-commit Git hook][post-commit-docs]: -## How to +> This hook is invoked by git-commit. It takes no parameters, and is invoked after a +> commit is made. -- Step 1: Create a new [`prepare-commit-msg`][prepare-commit-msg-docs] Git hook by running the following commands from the root of the Git repository: +A combination of these two hooks allows for enforcing the usage of commitizen so that +whenever a commit is about to be created, commitizen is used for creating the commit +message. Running `git commit` or `git commit -m "..."` for example, would trigger +commitizen and use the generated commit message for the commit. -```sh -cd .git/hooks -touch prepare-commit-msg -chmod +x prepare-commit-msg -``` +## Installation -- Step 2: Edit the newly created file and add the following content: +Copy the hooks from [here](https://github.com/commitizen-tools/hooks) into the `.git/hooks` folder and make them + executable by running the following commands from the root of your Git repository: -```sh -#!/bin/sh -COMMIT_MSG_FILE=$1 -exec < /dev/tty && cz commit --dry-run --write-message-to-file $COMMIT_MSG_FILE || true +```bash +wget -o .git/hooks/prepare-commit-msg https://github.com/commitizen-tools/hooks/prepare-commit-msg.py +chmod +x .git/hooks/prepare-commit-msg +wget -o .git/hooks/post-commit https://github.com/commitizen-tools/hooks/post-commit.py +chmod +x .git/hooks/post-commit ``` -See the Git hooks documentation on [`prepare-commit-msg` hooks][prepare-commit-msg-docs] for details on how this works. - -[prepare-commit-msg-docs]: https://git-scm.com/docs/githooks#_prepare_commit_msg +## Features -## Drawbacks +- Commits can be created using both `cz commit` and the regular `git commit` +- The hooks automatically create a backup of the commit message that can be reused if + the commit failed +- The commit message backup can also be used via `cz commit --retry` -If additional hooks are used (e.g. pre-commit) that prevent a commit from being created, -the message has to be created from scratch when commiting again. +[post-commit-docs]: https://git-scm.com/docs/githooks#_post_commit +[prepare-commit-msg-docs]: https://git-scm.com/docs/githooks#_prepare_commit_msg From 73a4ba7901c0e2e7eac4fbdc1aa26257007fa886 Mon Sep 17 00:00:00 2001 From: Santiago Fraire Date: Mon, 1 May 2023 20:44:16 +0200 Subject: [PATCH 27/28] docs(jenkins): update example to reflect new docker image with entrypoint --- docs/tutorials/jenkins_pipeline.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/docs/tutorials/jenkins_pipeline.md b/docs/tutorials/jenkins_pipeline.md index ef39cece84..fb87820c4c 100644 --- a/docs/tutorials/jenkins_pipeline.md +++ b/docs/tutorials/jenkins_pipeline.md @@ -37,7 +37,8 @@ pipeline { def useCz(String authorName = 'Jenkins CI Server', String authorEmail = 'your-jenkins@email.com', String image = 'registry.hub.docker.com/commitizen/commitizen:latest', Closure body) { docker .image(image) - .inside("-u 0 -v $WORKSPACE:/workspace -w /workspace -e GIT_AUTHOR_NAME='${authorName}' -e GIT_AUTHOR_EMAIL='${authorEmail}'") { + .inside("-u 0 -v $WORKSPACE:/workspace -w /workspace -e GIT_AUTHOR_NAME='${authorName}' -e GIT_AUTHOR_EMAIL='${authorEmail}' -entrypoint='/bin/sh'") { + sh 'git config --global --add safe.directory "*"' sh "git config --global user.email '${authorName}'" sh "git config --global user.name '${authorEmail}'" body() From 672ff94cf7eb5d3133671a6a860c8c119695d02d Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Mon, 1 May 2023 18:45:09 +0000 Subject: [PATCH 28/28] =?UTF-8?q?bump:=20version=203.1.1=20=E2=86=92=203.2?= =?UTF-8?q?.0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .pre-commit-config.yaml | 2 +- CHANGELOG.md | 20 ++++++++++++++++++++ commitizen/__version__.py | 2 +- pyproject.toml | 4 ++-- 4 files changed, 24 insertions(+), 4 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 322bd0d92d..1ea3e8482b 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -20,7 +20,7 @@ repos: - id: no-commit-to-branch - repo: https://github.com/commitizen-tools/commitizen - rev: v3.1.1 # automatically updated by Commitizen + rev: v3.2.0 # automatically updated by Commitizen hooks: - id: commitizen - id: commitizen-branch diff --git a/CHANGELOG.md b/CHANGELOG.md index 3e765c9c22..48aa326456 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,24 @@ +## v3.2.0 (2023-05-01) + +### Feat + +- **hooks**: add prepare-commit-msg and post-commit hooks +- **commit**: add --write-message-to-file option + +### Fix + +- **bump**: better match for change_type when finding increment +- **changelog**: breaking change on additional types for conventional commits +- **bump**: breaking changes on additional types for conventional commits +- improve errors message when empty .cz.json found +- **init**: poetry detection +- bump decli which is type hinted + +### Refactor + +- **commit**: change type of write_message_to_file to path + ## v3.1.1 (2023-04-28) ### Fix diff --git a/commitizen/__version__.py b/commitizen/__version__.py index d539d50ceb..11731085c0 100644 --- a/commitizen/__version__.py +++ b/commitizen/__version__.py @@ -1 +1 @@ -__version__ = "3.1.1" +__version__ = "3.2.0" diff --git a/pyproject.toml b/pyproject.toml index 98574e8a3b..95e8363aad 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,5 +1,5 @@ [tool.commitizen] -version = "3.1.1" +version = "3.2.0" tag_format = "v$version" version_files = [ "pyproject.toml:version", @@ -9,7 +9,7 @@ version_files = [ [tool.poetry] name = "commitizen" -version = "3.1.1" +version = "3.2.0" description = "Python commitizen client tool" authors = ["Santiago Fraire "] license = "MIT"