From f485108485ed61b49df02779f741000159ba32ae Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 21 Mar 2024 01:09:08 +0000 Subject: [PATCH 01/18] build(deps): bump importlib-metadata from 7.0.2 to 7.1.0 Bumps [importlib-metadata](https://github.com/python/importlib_metadata) from 7.0.2 to 7.1.0. - [Release notes](https://github.com/python/importlib_metadata/releases) - [Changelog](https://github.com/python/importlib_metadata/blob/main/NEWS.rst) - [Commits](https://github.com/python/importlib_metadata/compare/v7.0.2...v7.1.0) --- updated-dependencies: - dependency-name: importlib-metadata dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- poetry.lock | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/poetry.lock b/poetry.lock index 4f0fbb5deb..923d0ba013 100644 --- a/poetry.lock +++ b/poetry.lock @@ -496,13 +496,13 @@ files = [ [[package]] name = "importlib-metadata" -version = "7.0.2" +version = "7.1.0" description = "Read metadata from Python packages" optional = false python-versions = ">=3.8" files = [ - {file = "importlib_metadata-7.0.2-py3-none-any.whl", hash = "sha256:f4bc4c0c070c490abf4ce96d715f68e95923320370efb66143df00199bb6c100"}, - {file = "importlib_metadata-7.0.2.tar.gz", hash = "sha256:198f568f3230878cb1b44fbd7975f87906c22336dba2e4a7f05278c281fbd792"}, + {file = "importlib_metadata-7.1.0-py3-none-any.whl", hash = "sha256:30962b96c0c223483ed6cc7280e7f0199feb01a0e40cfae4d4450fc6fab1f570"}, + {file = "importlib_metadata-7.1.0.tar.gz", hash = "sha256:b78938b926ee8d5f020fc4772d487045805a55ddbad2ecf21c6d60938dc7fcd2"}, ] [package.dependencies] @@ -511,7 +511,7 @@ zipp = ">=0.5" [package.extras] docs = ["furo", "jaraco.packaging (>=9.3)", "jaraco.tidelift (>=1.4)", "rst.linker (>=1.9)", "sphinx (>=3.5)", "sphinx-lint"] perf = ["ipython"] -testing = ["flufl.flake8", "importlib-resources (>=1.3)", "packaging", "pyfakefs", "pytest (>=6)", "pytest-checkdocs (>=2.4)", "pytest-cov", "pytest-enabler (>=2.2)", "pytest-mypy", "pytest-perf (>=0.9.2)", "pytest-ruff (>=0.2.1)"] +testing = ["flufl.flake8", "importlib-resources (>=1.3)", "jaraco.test (>=5.4)", "packaging", "pyfakefs", "pytest (>=6)", "pytest-checkdocs (>=2.4)", "pytest-cov", "pytest-enabler (>=2.2)", "pytest-mypy", "pytest-perf (>=0.9.2)", "pytest-ruff (>=0.2.1)"] [[package]] name = "iniconfig" From 49dc1bec07019e7721652f9b17d9652ecd196956 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 22 Mar 2024 01:32:38 +0000 Subject: [PATCH 02/18] build(deps-dev): bump pytest-mock from 3.12.0 to 3.14.0 Bumps [pytest-mock](https://github.com/pytest-dev/pytest-mock) from 3.12.0 to 3.14.0. - [Release notes](https://github.com/pytest-dev/pytest-mock/releases) - [Changelog](https://github.com/pytest-dev/pytest-mock/blob/main/CHANGELOG.rst) - [Commits](https://github.com/pytest-dev/pytest-mock/compare/v3.12.0...v3.14.0) --- updated-dependencies: - dependency-name: pytest-mock dependency-type: direct:development update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- poetry.lock | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/poetry.lock b/poetry.lock index 923d0ba013..d91e6a7d02 100644 --- a/poetry.lock +++ b/poetry.lock @@ -1117,17 +1117,17 @@ pytest = ">=3.6" [[package]] name = "pytest-mock" -version = "3.12.0" +version = "3.14.0" description = "Thin-wrapper around the mock package for easier use with pytest" optional = false python-versions = ">=3.8" files = [ - {file = "pytest-mock-3.12.0.tar.gz", hash = "sha256:31a40f038c22cad32287bb43932054451ff5583ff094bca6f675df2f8bc1a6e9"}, - {file = "pytest_mock-3.12.0-py3-none-any.whl", hash = "sha256:0972719a7263072da3a21c7f4773069bcc7486027d7e8e1f81d98a47e701bc4f"}, + {file = "pytest-mock-3.14.0.tar.gz", hash = "sha256:2719255a1efeceadbc056d6bf3df3d1c5015530fb40cf347c0f9afac88410bd0"}, + {file = "pytest_mock-3.14.0-py3-none-any.whl", hash = "sha256:0b72c38033392a5f4621342fe11e9219ac11ec9d375f8e2a0c164539e0d70f6f"}, ] [package.dependencies] -pytest = ">=5.0" +pytest = ">=6.2.5" [package.extras] dev = ["pre-commit", "pytest-asyncio", "tox"] From 00daf2ae360e3332b68e11783d2d08a53a547f90 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 22 Mar 2024 01:33:20 +0000 Subject: [PATCH 03/18] build(deps-dev): bump ruff from 0.3.3 to 0.3.4 Bumps [ruff](https://github.com/astral-sh/ruff) from 0.3.3 to 0.3.4. - [Release notes](https://github.com/astral-sh/ruff/releases) - [Changelog](https://github.com/astral-sh/ruff/blob/main/CHANGELOG.md) - [Commits](https://github.com/astral-sh/ruff/compare/v0.3.3...v0.3.4) --- updated-dependencies: - dependency-name: ruff dependency-type: direct:development update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- poetry.lock | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/poetry.lock b/poetry.lock index d91e6a7d02..d208512744 100644 --- a/poetry.lock +++ b/poetry.lock @@ -1407,28 +1407,28 @@ use-chardet-on-py3 = ["chardet (>=3.0.2,<6)"] [[package]] name = "ruff" -version = "0.3.3" +version = "0.3.4" description = "An extremely fast Python linter and code formatter, written in Rust." optional = false python-versions = ">=3.7" files = [ - {file = "ruff-0.3.3-py3-none-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl", hash = "sha256:973a0e388b7bc2e9148c7f9be8b8c6ae7471b9be37e1cc732f8f44a6f6d7720d"}, - {file = "ruff-0.3.3-py3-none-macosx_10_12_x86_64.whl", hash = "sha256:cfa60d23269d6e2031129b053fdb4e5a7b0637fc6c9c0586737b962b2f834493"}, - {file = "ruff-0.3.3-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:1eca7ff7a47043cf6ce5c7f45f603b09121a7cc047447744b029d1b719278eb5"}, - {file = "ruff-0.3.3-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:e7d3f6762217c1da954de24b4a1a70515630d29f71e268ec5000afe81377642d"}, - {file = "ruff-0.3.3-py3-none-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:b24c19e8598916d9c6f5a5437671f55ee93c212a2c4c569605dc3842b6820386"}, - {file = "ruff-0.3.3-py3-none-manylinux_2_17_ppc64.manylinux2014_ppc64.whl", hash = "sha256:5a6cbf216b69c7090f0fe4669501a27326c34e119068c1494f35aaf4cc683778"}, - {file = "ruff-0.3.3-py3-none-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:352e95ead6964974b234e16ba8a66dad102ec7bf8ac064a23f95371d8b198aab"}, - {file = "ruff-0.3.3-py3-none-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:8d6ab88c81c4040a817aa432484e838aaddf8bfd7ca70e4e615482757acb64f8"}, - {file = "ruff-0.3.3-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:79bca3a03a759cc773fca69e0bdeac8abd1c13c31b798d5bb3c9da4a03144a9f"}, - {file = "ruff-0.3.3-py3-none-musllinux_1_2_aarch64.whl", hash = "sha256:2700a804d5336bcffe063fd789ca2c7b02b552d2e323a336700abb8ae9e6a3f8"}, - {file = "ruff-0.3.3-py3-none-musllinux_1_2_armv7l.whl", hash = "sha256:fd66469f1a18fdb9d32e22b79f486223052ddf057dc56dea0caaf1a47bdfaf4e"}, - {file = "ruff-0.3.3-py3-none-musllinux_1_2_i686.whl", hash = "sha256:45817af234605525cdf6317005923bf532514e1ea3d9270acf61ca2440691376"}, - {file = "ruff-0.3.3-py3-none-musllinux_1_2_x86_64.whl", hash = "sha256:0da458989ce0159555ef224d5b7c24d3d2e4bf4c300b85467b08c3261c6bc6a8"}, - {file = "ruff-0.3.3-py3-none-win32.whl", hash = "sha256:f2831ec6a580a97f1ea82ea1eda0401c3cdf512cf2045fa3c85e8ef109e87de0"}, - {file = "ruff-0.3.3-py3-none-win_amd64.whl", hash = "sha256:be90bcae57c24d9f9d023b12d627e958eb55f595428bafcb7fec0791ad25ddfc"}, - {file = "ruff-0.3.3-py3-none-win_arm64.whl", hash = "sha256:0171aab5fecdc54383993389710a3d1227f2da124d76a2784a7098e818f92d61"}, - {file = "ruff-0.3.3.tar.gz", hash = "sha256:38671be06f57a2f8aba957d9f701ea889aa5736be806f18c0cd03d6ff0cbca8d"}, + {file = "ruff-0.3.4-py3-none-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl", hash = "sha256:60c870a7d46efcbc8385d27ec07fe534ac32f3b251e4fc44b3cbfd9e09609ef4"}, + {file = "ruff-0.3.4-py3-none-macosx_10_12_x86_64.whl", hash = "sha256:6fc14fa742e1d8f24910e1fff0bd5e26d395b0e0e04cc1b15c7c5e5fe5b4af91"}, + {file = "ruff-0.3.4-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:d3ee7880f653cc03749a3bfea720cf2a192e4f884925b0cf7eecce82f0ce5854"}, + {file = "ruff-0.3.4-py3-none-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:cf133dd744f2470b347f602452a88e70dadfbe0fcfb5fd46e093d55da65f82f7"}, + {file = "ruff-0.3.4-py3-none-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:3f3860057590e810c7ffea75669bdc6927bfd91e29b4baa9258fd48b540a4365"}, + {file = "ruff-0.3.4-py3-none-manylinux_2_17_ppc64.manylinux2014_ppc64.whl", hash = "sha256:986f2377f7cf12efac1f515fc1a5b753c000ed1e0a6de96747cdf2da20a1b369"}, + {file = "ruff-0.3.4-py3-none-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:c4fd98e85869603e65f554fdc5cddf0712e352fe6e61d29d5a6fe087ec82b76c"}, + {file = "ruff-0.3.4-py3-none-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:64abeed785dad51801b423fa51840b1764b35d6c461ea8caef9cf9e5e5ab34d9"}, + {file = "ruff-0.3.4-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:df52972138318bc7546d92348a1ee58449bc3f9eaf0db278906eb511889c4b50"}, + {file = "ruff-0.3.4-py3-none-musllinux_1_2_aarch64.whl", hash = "sha256:98e98300056445ba2cc27d0b325fd044dc17fcc38e4e4d2c7711585bd0a958ed"}, + {file = "ruff-0.3.4-py3-none-musllinux_1_2_armv7l.whl", hash = "sha256:519cf6a0ebed244dce1dc8aecd3dc99add7a2ee15bb68cf19588bb5bf58e0488"}, + {file = "ruff-0.3.4-py3-none-musllinux_1_2_i686.whl", hash = "sha256:bb0acfb921030d00070539c038cd24bb1df73a2981e9f55942514af8b17be94e"}, + {file = "ruff-0.3.4-py3-none-musllinux_1_2_x86_64.whl", hash = "sha256:cf187a7e7098233d0d0c71175375c5162f880126c4c716fa28a8ac418dcf3378"}, + {file = "ruff-0.3.4-py3-none-win32.whl", hash = "sha256:af27ac187c0a331e8ef91d84bf1c3c6a5dea97e912a7560ac0cef25c526a4102"}, + {file = "ruff-0.3.4-py3-none-win_amd64.whl", hash = "sha256:de0d5069b165e5a32b3c6ffbb81c350b1e3d3483347196ffdf86dc0ef9e37dd6"}, + {file = "ruff-0.3.4-py3-none-win_arm64.whl", hash = "sha256:6810563cc08ad0096b57c717bd78aeac888a1bfd38654d9113cb3dc4d3f74232"}, + {file = "ruff-0.3.4.tar.gz", hash = "sha256:f0f4484c6541a99862b693e13a151435a279b271cff20e37101116a21e2a1ad1"}, ] [[package]] From d34b94686815c74ed8df55b7f14f1566c3101101 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 25 Mar 2024 01:48:47 +0000 Subject: [PATCH 04/18] build(deps-dev): bump mkdocs-material from 9.5.14 to 9.5.15 Bumps [mkdocs-material](https://github.com/squidfunk/mkdocs-material) from 9.5.14 to 9.5.15. - [Release notes](https://github.com/squidfunk/mkdocs-material/releases) - [Changelog](https://github.com/squidfunk/mkdocs-material/blob/master/CHANGELOG) - [Commits](https://github.com/squidfunk/mkdocs-material/compare/9.5.14...9.5.15) --- updated-dependencies: - dependency-name: mkdocs-material dependency-type: direct:development update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- poetry.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/poetry.lock b/poetry.lock index d208512744..961540443e 100644 --- a/poetry.lock +++ b/poetry.lock @@ -744,13 +744,13 @@ min-versions = ["babel (==2.9.0)", "click (==7.0)", "colorama (==0.4)", "ghp-imp [[package]] name = "mkdocs-material" -version = "9.5.14" +version = "9.5.15" description = "Documentation that simply works" optional = false python-versions = ">=3.8" files = [ - {file = "mkdocs_material-9.5.14-py3-none-any.whl", hash = "sha256:a45244ac221fda46ecf8337f00ec0e5cb5348ab9ffb203ca2a0c313b0d4dbc27"}, - {file = "mkdocs_material-9.5.14.tar.gz", hash = "sha256:2a1f8e67cda2587ab93ecea9ba42d0ca61d1d7b5fad8cf690eeaeb39dcd4b9af"}, + {file = "mkdocs_material-9.5.15-py3-none-any.whl", hash = "sha256:e5c96dec3d19491de49ca643fc1dbb92b278e43cdb816c775bc47db77d9b62fb"}, + {file = "mkdocs_material-9.5.15.tar.gz", hash = "sha256:39f03cca45e82bf54eb7456b5a18bd252eabfdd67f237a229471484a0a4d4635"}, ] [package.dependencies] From 8daca3faf836e49ffd65da93e0b7c87e101f5071 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 25 Mar 2024 01:46:39 +0000 Subject: [PATCH 05/18] build(deps-dev): bump pytest-cov from 4.1.0 to 5.0.0 Bumps [pytest-cov](https://github.com/pytest-dev/pytest-cov) from 4.1.0 to 5.0.0. - [Changelog](https://github.com/pytest-dev/pytest-cov/blob/master/CHANGELOG.rst) - [Commits](https://github.com/pytest-dev/pytest-cov/compare/v4.1.0...v5.0.0) --- updated-dependencies: - dependency-name: pytest-cov dependency-type: direct:development update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- poetry.lock | 12 ++++++------ pyproject.toml | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/poetry.lock b/poetry.lock index 961540443e..2d49e41b5a 100644 --- a/poetry.lock +++ b/poetry.lock @@ -1070,13 +1070,13 @@ testing = ["argcomplete", "attrs (>=19.2)", "hypothesis (>=3.56)", "mock", "pygm [[package]] name = "pytest-cov" -version = "4.1.0" +version = "5.0.0" description = "Pytest plugin for measuring coverage." optional = false -python-versions = ">=3.7" +python-versions = ">=3.8" files = [ - {file = "pytest-cov-4.1.0.tar.gz", hash = "sha256:3904b13dfbfec47f003b8e77fd5b589cd11904a21ddf1ab38a64f204d6a10ef6"}, - {file = "pytest_cov-4.1.0-py3-none-any.whl", hash = "sha256:6ba70b9e97e69fcc3fb45bfeab2d0a138fb65c4d0d6a41ef33983ad114be8c3a"}, + {file = "pytest-cov-5.0.0.tar.gz", hash = "sha256:5837b58e9f6ebd335b0f8060eecce69b662415b16dc503883a02f45dfeb14857"}, + {file = "pytest_cov-5.0.0-py3-none-any.whl", hash = "sha256:4f0764a1219df53214206bf1feea4633c3b558a2925c8b59f144f682861ce652"}, ] [package.dependencies] @@ -1084,7 +1084,7 @@ coverage = {version = ">=5.2.1", extras = ["toml"]} pytest = ">=4.6" [package.extras] -testing = ["fields", "hunter", "process-tests", "pytest-xdist", "six", "virtualenv"] +testing = ["fields", "hunter", "process-tests", "pytest-xdist", "virtualenv"] [[package]] name = "pytest-datadir" @@ -1766,4 +1766,4 @@ testing = ["big-O", "jaraco.functools", "jaraco.itertools", "more-itertools", "p [metadata] lock-version = "2.0" python-versions = ">=3.8" -content-hash = "e30411f9893b8c5788c5665a2a888596bcc1c170ac3681f868822e69a4ae1f46" +content-hash = "614f9b1db867d5b7f954c318309b0e7b18951ed7be6d8016af79a08b8c2c7a89" diff --git a/pyproject.toml b/pyproject.toml index 30d548890a..82f415ff34 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -54,7 +54,7 @@ importlib_metadata = { version = ">=4.13,<8"} ipython = "^8.0" # test pytest = ">=7.2,<9.0" -pytest-cov = "^4.0" +pytest-cov = ">=4,<6" pytest-mock = "^3.10" pytest-regressions = "^2.4.0" pytest-freezer = "^0.4.6" From 3212eaa0621dcb7634a0f944eeb7663b136d570c Mon Sep 17 00:00:00 2001 From: crai0 Date: Fri, 15 Mar 2024 18:02:26 +0100 Subject: [PATCH 06/18] feat(commit): add retry_after_failure config option and --no-retry flag --- commitizen/cli.py | 6 ++++++ commitizen/commands/commit.py | 19 +++++++++++++++---- commitizen/defaults.py | 2 ++ 3 files changed, 23 insertions(+), 4 deletions(-) diff --git a/commitizen/cli.py b/commitizen/cli.py index c25bd4f713..a442803d7f 100644 --- a/commitizen/cli.py +++ b/commitizen/cli.py @@ -123,6 +123,12 @@ def __call__( "action": "store_true", "help": "retry last commit", }, + { + "name": ["--no-retry"], + "action": "store_true", + "default": False, + "help": "skip retry if retry_after_failure is set to true", + }, { "name": "--dry-run", "action": "store_true", diff --git a/commitizen/commands/commit.py b/commitizen/commands/commit.py index b8e5eed6d4..390741afc1 100644 --- a/commitizen/commands/commit.py +++ b/commitizen/commands/commit.py @@ -33,13 +33,16 @@ def __init__(self, config: BaseConfig, arguments: dict): self.arguments = arguments self.temp_file: str = os.path.join( tempfile.gettempdir(), - "cz.commit{user}.backup".format(user=os.environ.get("USER", "")), + "cz.commit%{user}%{project_root}.backup".format( + user=os.environ.get("USER", ""), + project_root=str(git.find_git_project_root()).replace("/", "%"), + ), ) - def read_backup_message(self) -> str: + def read_backup_message(self) -> str | None: # Check the commit backup file exists if not os.path.isfile(self.temp_file): - raise NoCommitBackupError() + return None # Read commit message from backup with open(self.temp_file, encoding=self.encoding) as f: @@ -65,7 +68,7 @@ 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") + write_message_to_file: bool = self.arguments.get("write_message_to_file") is_all: bool = self.arguments.get("all") if is_all: @@ -78,9 +81,17 @@ def __call__(self): raise NotAllowed(f"{write_message_to_file} is a directory") retry: bool = self.arguments.get("retry") + no_retry: bool = self.arguments.get("no_retry") + retry_after_failure: bool = self.config.settings.get("retry_after_failure") if retry: m = self.read_backup_message() + if m is None: + raise NoCommitBackupError() + elif retry_after_failure and not no_retry: + m = self.read_backup_message() + if m is None: + m = self.prompt_commit_questions() else: m = self.prompt_commit_questions() diff --git a/commitizen/defaults.py b/commitizen/defaults.py index 7aa2c793c5..071efd10b9 100644 --- a/commitizen/defaults.py +++ b/commitizen/defaults.py @@ -37,6 +37,7 @@ class Settings(TypedDict, total=False): version_type: str | None tag_format: str bump_message: str | None + retry_after_failure: bool allow_abort: bool allowed_prefixes: list[str] changelog_file: str @@ -77,6 +78,7 @@ class Settings(TypedDict, total=False): "version_scheme": None, "tag_format": "$version", # example v$version "bump_message": None, # bumped v$current_version to $new_version + "retry_after_failure": False, "allow_abort": False, "allowed_prefixes": [ "Merge", From 25320034fadf0bd30b67dedfbe3e07a1c6ef0bf5 Mon Sep 17 00:00:00 2001 From: crai0 Date: Fri, 15 Mar 2024 18:50:41 +0100 Subject: [PATCH 07/18] test(commit): add tests for retry_after_failure config option and --no-retry flag --- tests/commands/test_commit_command.py | 63 +++++++++++++++++++++++++++ tests/test_conf.py | 2 + 2 files changed, 65 insertions(+) diff --git a/tests/commands/test_commit_command.py b/tests/commands/test_commit_command.py index e3f9989823..545defe0e4 100644 --- a/tests/commands/test_commit_command.py +++ b/tests/commands/test_commit_command.py @@ -94,6 +94,69 @@ def test_commit_retry_works(config, mocker: MockFixture): assert not os.path.isfile(temp_file) +@pytest.mark.usefixtures("staging_is_clean") +def test_commit_retry_after_failure_no_backup(config, mocker: MockFixture): + prompt_mock = mocker.patch("questionary.prompt") + prompt_mock.return_value = { + "prefix": "feat", + "subject": "user created", + "scope": "", + "is_breaking_change": False, + "body": "closes #21", + "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") + + config.settings["retry_after_failure"] = True + commands.Commit(config, {})() + + commit_mock.assert_called_with("feat: user created\n\ncloses #21", args="") + prompt_mock.assert_called_once() + success_mock.assert_called_once() + + +@pytest.mark.usefixtures("staging_is_clean") +def test_commit_retry_after_failure_works(config, mocker: MockFixture): + prompt_mock = mocker.patch("questionary.prompt") + prompt_mock.return_value = { + "prefix": "feat", + "subject": "user created", + "scope": "", + "is_breaking_change": False, + "body": "closes #21", + "footer": "", + } + + commit_mock = mocker.patch("commitizen.git.commit") + commit_mock.return_value = cmd.Command("", "error", b"", b"", 9) + error_mock = mocker.patch("commitizen.out.error") + + with pytest.raises(CommitError): + commit_cmd = commands.Commit(config, {}) + temp_file = commit_cmd.temp_file + commit_cmd() + + prompt_mock.assert_called_once() + error_mock.assert_called_once() + assert os.path.isfile(temp_file) + + # Previous commit failed, so retry should pick up the backup commit + # commit_mock = mocker.patch("commitizen.git.commit") + commit_mock.return_value = cmd.Command("success", "", b"", b"", 0) + success_mock = mocker.patch("commitizen.out.success") + + config.settings["retry_after_failure"] = True + commands.Commit(config, {})() + + commit_mock.assert_called_with("feat: user created\n\ncloses #21", args="") + prompt_mock.assert_called_once() + success_mock.assert_called_once() + assert not os.path.isfile(temp_file) + + @pytest.mark.usefixtures("staging_is_clean") def test_commit_command_with_dry_run_option(config, mocker: MockFixture): prompt_mock = mocker = mocker.patch("questionary.prompt") diff --git a/tests/test_conf.py b/tests/test_conf.py index dcac8e015c..a12bcdd35d 100644 --- a/tests/test_conf.py +++ b/tests/test_conf.py @@ -52,6 +52,7 @@ "version_scheme": None, "tag_format": "$version", "bump_message": None, + "retry_after_failure": False, "allow_abort": False, "allowed_prefixes": ["Merge", "Revert", "Pull request", "fixup!", "squash!"], "version_files": ["commitizen/__version__.py", "pyproject.toml"], @@ -80,6 +81,7 @@ "version_scheme": None, "tag_format": "$version", "bump_message": None, + "retry_after_failure": False, "allow_abort": False, "allowed_prefixes": ["Merge", "Revert", "Pull request", "fixup!", "squash!"], "version_files": ["commitizen/__version__.py", "pyproject.toml"], From f1c1e576fab6b2ab52ce03ad64a0bdda8f14605a Mon Sep 17 00:00:00 2001 From: crai0 Date: Fri, 15 Mar 2024 19:02:20 +0100 Subject: [PATCH 08/18] refactor(utils): move backup path creation to utils --- commitizen/commands/commit.py | 9 ++------- commitizen/cz/utils.py | 13 +++++++++++++ 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/commitizen/commands/commit.py b/commitizen/commands/commit.py index 390741afc1..f2ccc6b1af 100644 --- a/commitizen/commands/commit.py +++ b/commitizen/commands/commit.py @@ -7,6 +7,7 @@ from commitizen import factory, git, out from commitizen.config import BaseConfig from commitizen.cz.exceptions import CzException +from commitizen.cz.utils import get_backup_file_path from commitizen.exceptions import ( CommitError, CustomError, @@ -31,13 +32,7 @@ def __init__(self, config: BaseConfig, arguments: dict): self.encoding = config.settings["encoding"] self.cz = factory.commiter_factory(self.config) self.arguments = arguments - self.temp_file: str = os.path.join( - tempfile.gettempdir(), - "cz.commit%{user}%{project_root}.backup".format( - user=os.environ.get("USER", ""), - project_root=str(git.find_git_project_root()).replace("/", "%"), - ), - ) + self.temp_file: str = get_backup_file_path() def read_backup_message(self) -> str | None: # Check the commit backup file exists diff --git a/commitizen/cz/utils.py b/commitizen/cz/utils.py index 71dac105a7..93c63a2213 100644 --- a/commitizen/cz/utils.py +++ b/commitizen/cz/utils.py @@ -1,6 +1,9 @@ import re +import os +import tempfile from commitizen.cz import exceptions +from commitizen import git def required_validator(answer, msg=None): @@ -15,3 +18,13 @@ def multiple_line_breaker(answer, sep="|"): def strip_local_version(version: str) -> str: return re.sub(r"\+.+", "", version) + + +def get_backup_file_path() -> str: + return os.path.join( + tempfile.gettempdir(), + "cz.commit%{user}%{project_root}.backup".format( + user=os.environ.get("USER", ""), + project_root=str(git.find_git_project_root()).replace("/", "%"), + ), + ) From e4b7e01fd181c06231f5975df303daff222fd5ec Mon Sep 17 00:00:00 2001 From: crai0 Date: Fri, 15 Mar 2024 19:16:54 +0100 Subject: [PATCH 09/18] refactor(git-hooks): make git hooks use get_backup_file_path --- hooks/post-commit.py | 13 ++++++++----- hooks/prepare-commit-msg.py | 18 ++++++++---------- 2 files changed, 16 insertions(+), 15 deletions(-) diff --git a/hooks/post-commit.py b/hooks/post-commit.py index c2faebb738..a0ad5a7749 100755 --- a/hooks/post-commit.py +++ b/hooks/post-commit.py @@ -1,13 +1,16 @@ #!/usr/bin/env python -import os -import tempfile from pathlib import Path +try: + from commitizen.cz.utils import get_backup_file_path +except ImportError as error: + print("could not import commitizen:") + print(error) + exit(1) + def post_commit(): - backup_file = Path( - tempfile.gettempdir(), f"cz.commit{os.environ.get('USER', '')}.backup" - ) + backup_file = Path(get_backup_file_path()) # remove backup file if it exists if backup_file.is_file(): diff --git a/hooks/prepare-commit-msg.py b/hooks/prepare-commit-msg.py index 58beb3a0f8..d1ccf169cf 100755 --- a/hooks/prepare-commit-msg.py +++ b/hooks/prepare-commit-msg.py @@ -1,19 +1,19 @@ #!/usr/bin/env python -import os import shutil import subprocess import sys -import tempfile from pathlib import Path from subprocess import CalledProcessError +try: + from commitizen.cz.utils import get_backup_file_path +except ImportError as error: + print("could not import commitizen:") + print(error) + exit(1) -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 +def prepare_commit_msg(commit_msg_file: Path) -> int: # check if the commit message needs to be generated using commitizen if ( subprocess.run( @@ -27,9 +27,7 @@ def prepare_commit_msg(commit_msg_file: Path) -> int: ).returncode != 0 ): - backup_file = Path( - tempfile.gettempdir(), f"cz.commit{os.environ.get('USER', '')}.backup" - ) + backup_file = Path(get_backup_file_path()) if backup_file.is_file(): # confirm if commit message from backup file should be reused From 0c95c160d715f5cad5bfc709d8ee4b0780c73641 Mon Sep 17 00:00:00 2001 From: crai0 Date: Fri, 15 Mar 2024 19:27:59 +0100 Subject: [PATCH 10/18] refactor(commit): remove unused tempfile import --- commitizen/commands/commit.py | 1 - 1 file changed, 1 deletion(-) diff --git a/commitizen/commands/commit.py b/commitizen/commands/commit.py index f2ccc6b1af..c9712a0fc7 100644 --- a/commitizen/commands/commit.py +++ b/commitizen/commands/commit.py @@ -1,6 +1,5 @@ import contextlib import os -import tempfile import questionary From e6b5e8bd882bdd0892877b9927bf1201af4f7113 Mon Sep 17 00:00:00 2001 From: crai0 Date: Fri, 15 Mar 2024 20:26:36 +0100 Subject: [PATCH 11/18] test(commit): add test for --no-retry flag --- tests/commands/test_commit_command.py | 48 +++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/tests/commands/test_commit_command.py b/tests/commands/test_commit_command.py index 545defe0e4..f2f4f174c6 100644 --- a/tests/commands/test_commit_command.py +++ b/tests/commands/test_commit_command.py @@ -157,6 +157,54 @@ def test_commit_retry_after_failure_works(config, mocker: MockFixture): assert not os.path.isfile(temp_file) +@pytest.mark.usefixtures("staging_is_clean") +def test_commit_retry_after_failure_with_no_retry_works(config, mocker: MockFixture): + prompt_mock = mocker.patch("questionary.prompt") + prompt_mock.return_value = { + "prefix": "feat", + "subject": "user created", + "scope": "", + "is_breaking_change": False, + "body": "closes #21", + "footer": "", + } + + commit_mock = mocker.patch("commitizen.git.commit") + commit_mock.return_value = cmd.Command("", "error", b"", b"", 9) + error_mock = mocker.patch("commitizen.out.error") + + with pytest.raises(CommitError): + commit_cmd = commands.Commit(config, {}) + temp_file = commit_cmd.temp_file + commit_cmd() + + prompt_mock.assert_called_once() + error_mock.assert_called_once() + assert os.path.isfile(temp_file) + + # provide different prompt to test that --no-retry ignore backup file + prompt_mock = mocker.patch("questionary.prompt") + prompt_mock.return_value = { + "prefix": "feat", + "subject": "user created", + "scope": "", + "is_breaking_change": False, + "body": "closes #22", + "footer": "", + } + + commit_mock.return_value = cmd.Command("success", "", b"", b"", 0) + success_mock = mocker.patch("commitizen.out.success") + + config.settings["retry_after_failure"] = True + commands.Commit(config, {"no_retry": True})() + + commit_mock.assert_called_with("feat: user created\n\ncloses #22", args="") + prompt_mock.assert_called() + success_mock.assert_called_once() + assert not os.path.isfile(temp_file) + + @pytest.mark.usefixtures("staging_is_clean") def test_commit_command_with_dry_run_option(config, mocker: MockFixture): prompt_mock = mocker = mocker.patch("questionary.prompt") From d3f2b68fa012a4c9a9030f7da93c2f268803259e Mon Sep 17 00:00:00 2001 From: crai0 Date: Fri, 15 Mar 2024 20:50:01 +0100 Subject: [PATCH 12/18] docs: add retry_after_failure config and retry options for commit command --- docs/commit.md | 7 +++++++ docs/config.md | 9 +++++++++ 2 files changed, 16 insertions(+) diff --git a/docs/commit.md b/docs/commit.md index 2215e0d805..54c792f743 100644 --- a/docs/commit.md +++ b/docs/commit.md @@ -29,3 +29,10 @@ For example, using the `-S` option on `git commit` to sign a commit is now commi !!! note Deprecation warning: A commit can be signed off using `cz commit --signoff` or the shortcut `cz commit -s`. This syntax is now deprecated in favor of the new `cz commit -- -s` syntax. + +### Retry + +You can use `cz commit --retry` to reuse the last commit message when the previous commit attempt failed. +To automatically retry when running `cz commit`, you can set the `retry_after_failure` +configuration option to `true`. Running `cz commit --no-retry` makes commitizen ignore `retry_after_failure`, forcing +a new commit message to be prompted. diff --git a/docs/config.md b/docs/config.md index 391c20f0fc..d6ab12abcd 100644 --- a/docs/config.md +++ b/docs/config.md @@ -82,6 +82,14 @@ Default: `None` Create custom commit message, useful to skip ci. [Read more][bump_message] +### `retry_after_failure` + +Type: `bool` + +Default: `false` + +Automatically retry failed commit when running `cz commit`. [Read more][retry_after_failure] + ### `allow_abort` Type: `bool` @@ -380,6 +388,7 @@ setup( [bump_message]: bump.md#bump_message [major-version-zero]: bump.md#-major-version-zero [prerelease-offset]: bump.md#-prerelease_offset +[retry_after_failure]: commit.md#retry [allow_abort]: check.md#allow-abort [version-scheme]: bump.md#version-scheme [pre_bump_hooks]: bump.md#pre_bump_hooks From e2644c9f67cf17c8124f12ab7ab2352d48dbd5ce Mon Sep 17 00:00:00 2001 From: crai0 Date: Fri, 15 Mar 2024 21:17:18 +0100 Subject: [PATCH 13/18] refactor(commit): use Optional[str] instead of str | None --- commitizen/commands/commit.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/commitizen/commands/commit.py b/commitizen/commands/commit.py index c9712a0fc7..2489abaf29 100644 --- a/commitizen/commands/commit.py +++ b/commitizen/commands/commit.py @@ -1,6 +1,8 @@ import contextlib import os +from typing import Optional + import questionary from commitizen import factory, git, out @@ -33,7 +35,7 @@ def __init__(self, config: BaseConfig, arguments: dict): self.arguments = arguments self.temp_file: str = get_backup_file_path() - def read_backup_message(self) -> str | None: + def read_backup_message(self) -> Optional[str]: # Check the commit backup file exists if not os.path.isfile(self.temp_file): return None From 820ada2c005a53e64527b479a3181125c249bef9 Mon Sep 17 00:00:00 2001 From: crai0 Date: Fri, 15 Mar 2024 21:34:22 +0100 Subject: [PATCH 14/18] refactor(utils): convert git project root to posix path for backup file name --- commitizen/cz/utils.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/commitizen/cz/utils.py b/commitizen/cz/utils.py index 93c63a2213..d5bd63c6fc 100644 --- a/commitizen/cz/utils.py +++ b/commitizen/cz/utils.py @@ -21,10 +21,17 @@ def strip_local_version(version: str) -> str: def get_backup_file_path() -> str: + project_root = git.find_git_project_root() + + if project_root is None: + project = "" + else: + project = project_root.as_posix().replace("/", "%") + return os.path.join( tempfile.gettempdir(), - "cz.commit%{user}%{project_root}.backup".format( + "cz.commit%{user}%{project}.backup".format( user=os.environ.get("USER", ""), - project_root=str(git.find_git_project_root()).replace("/", "%"), + project=project, ), ) From 4f3931a49985d584b246fdf9df5a741581a160b3 Mon Sep 17 00:00:00 2001 From: crai0 Date: Fri, 15 Mar 2024 21:51:38 +0100 Subject: [PATCH 15/18] test(utils): add test for get_backup_file_path when git.find_project_root returns None --- tests/test_cz_utils.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/tests/test_cz_utils.py b/tests/test_cz_utils.py index 94cc7f5b87..25c960c9a7 100644 --- a/tests/test_cz_utils.py +++ b/tests/test_cz_utils.py @@ -1,4 +1,5 @@ import pytest +from pytest_mock import MockFixture from commitizen.cz import exceptions, utils @@ -17,3 +18,9 @@ def test_multiple_line_breaker(): result = utils.multiple_line_breaker(message, "is") assert result == "th\n\nthe first line | and th\n\nthe second line" + + +def test_get_backup_file_path_no_project_root(mocker: MockFixture): + project_root_mock = mocker.patch("commitizen.git.find_git_project_root") + project_root_mock.return_value = None + assert utils.get_backup_file_path() From fc3c1e9975fbc4181a89932b01a8928886d74b31 Mon Sep 17 00:00:00 2001 From: crai0 Date: Sat, 16 Mar 2024 19:48:54 +0100 Subject: [PATCH 16/18] test(commit): create new test for backup file creation and use fixture for other retry test cases --- tests/commands/test_commit_command.py | 112 ++++++++++---------------- 1 file changed, 42 insertions(+), 70 deletions(-) diff --git a/tests/commands/test_commit_command.py b/tests/commands/test_commit_command.py index f2f4f174c6..1930b2eaee 100644 --- a/tests/commands/test_commit_command.py +++ b/tests/commands/test_commit_command.py @@ -6,6 +6,7 @@ from commitizen import cmd, commands from commitizen.cz.exceptions import CzException +from commitizen.cz.utils import get_backup_file_path from commitizen.exceptions import ( CommitError, CustomError, @@ -25,6 +26,12 @@ def staging_is_clean(mocker: MockFixture, tmp_git_project): return tmp_git_project +@pytest.fixture +def backup_file(tmp_git_project): + with open(get_backup_file_path(), "w") as backup_file: + backup_file.write("backup commit") + + @pytest.mark.usefixtures("staging_is_clean") def test_commit(config, mocker: MockFixture): prompt_mock = mocker.patch("questionary.prompt") @@ -46,18 +53,7 @@ def test_commit(config, mocker: MockFixture): @pytest.mark.usefixtures("staging_is_clean") -def test_commit_retry_fails_no_backup(config, mocker: MockFixture): - commit_mock = mocker.patch("commitizen.git.commit") - commit_mock.return_value = cmd.Command("success", "", b"", b"", 0) - - with pytest.raises(NoCommitBackupError) as excinfo: - commands.Commit(config, {"retry": True})() - - assert NoCommitBackupError.message in str(excinfo.value) - - -@pytest.mark.usefixtures("staging_is_clean") -def test_commit_retry_works(config, mocker: MockFixture): +def test_commit_backup_on_failure(config, mocker: MockFixture): prompt_mock = mocker.patch("questionary.prompt") prompt_mock.return_value = { "prefix": "feat", @@ -81,15 +77,32 @@ def test_commit_retry_works(config, mocker: MockFixture): error_mock.assert_called_once() assert os.path.isfile(temp_file) - # Previous commit failed, so retry should pick up the backup commit - # commit_mock = mocker.patch("commitizen.git.commit") + +@pytest.mark.usefixtures("staging_is_clean") +def test_commit_retry_fails_no_backup(config, mocker: MockFixture): + commit_mock = mocker.patch("commitizen.git.commit") + commit_mock.return_value = cmd.Command("success", "", b"", b"", 0) + + with pytest.raises(NoCommitBackupError) as excinfo: + commands.Commit(config, {"retry": True})() + + assert NoCommitBackupError.message in str(excinfo.value) + + +@pytest.mark.usefixtures("staging_is_clean", "backup_file") +def test_commit_retry_works(config, mocker: MockFixture): + prompt_mock = mocker.patch("questionary.prompt") + + 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, {"retry": True})() + commit_cmd = commands.Commit(config, {"retry": True}) + temp_file = commit_cmd.temp_file + commit_cmd() - commit_mock.assert_called_with("feat: user created\n\ncloses #21", args="") - prompt_mock.assert_called_once() + commit_mock.assert_called_with("backup commit", args="") + prompt_mock.assert_not_called() success_mock.assert_called_once() assert not os.path.isfile(temp_file) @@ -118,46 +131,26 @@ def test_commit_retry_after_failure_no_backup(config, mocker: MockFixture): success_mock.assert_called_once() -@pytest.mark.usefixtures("staging_is_clean") +@pytest.mark.usefixtures("staging_is_clean", "backup_file") def test_commit_retry_after_failure_works(config, mocker: MockFixture): prompt_mock = mocker.patch("questionary.prompt") - prompt_mock.return_value = { - "prefix": "feat", - "subject": "user created", - "scope": "", - "is_breaking_change": False, - "body": "closes #21", - "footer": "", - } commit_mock = mocker.patch("commitizen.git.commit") - commit_mock.return_value = cmd.Command("", "error", b"", b"", 9) - error_mock = mocker.patch("commitizen.out.error") - - with pytest.raises(CommitError): - commit_cmd = commands.Commit(config, {}) - temp_file = commit_cmd.temp_file - commit_cmd() - - prompt_mock.assert_called_once() - error_mock.assert_called_once() - assert os.path.isfile(temp_file) - - # Previous commit failed, so retry should pick up the backup commit - # commit_mock = mocker.patch("commitizen.git.commit") commit_mock.return_value = cmd.Command("success", "", b"", b"", 0) success_mock = mocker.patch("commitizen.out.success") config.settings["retry_after_failure"] = True - commands.Commit(config, {})() + commit_cmd = commands.Commit(config, {}) + temp_file = commit_cmd.temp_file + commit_cmd() - commit_mock.assert_called_with("feat: user created\n\ncloses #21", args="") - prompt_mock.assert_called_once() + commit_mock.assert_called_with("backup commit", args="") + prompt_mock.assert_not_called() success_mock.assert_called_once() assert not os.path.isfile(temp_file) -@pytest.mark.usefixtures("staging_is_clean") +@pytest.mark.usefixtures("staging_is_clean", "backup_file") def test_commit_retry_after_failure_with_no_retry_works(config, mocker: MockFixture): prompt_mock = mocker.patch("questionary.prompt") prompt_mock.return_value = { @@ -170,37 +163,16 @@ def test_commit_retry_after_failure_with_no_retry_works(config, mocker: MockFixt } commit_mock = mocker.patch("commitizen.git.commit") - commit_mock.return_value = cmd.Command("", "error", b"", b"", 9) - error_mock = mocker.patch("commitizen.out.error") - - with pytest.raises(CommitError): - commit_cmd = commands.Commit(config, {}) - temp_file = commit_cmd.temp_file - commit_cmd() - - prompt_mock.assert_called_once() - error_mock.assert_called_once() - assert os.path.isfile(temp_file) - - # provide different prompt to test that --no-retry ignore backup file - prompt_mock = mocker.patch("questionary.prompt") - prompt_mock.return_value = { - "prefix": "feat", - "subject": "user created", - "scope": "", - "is_breaking_change": False, - "body": "closes #22", - "footer": "", - } - commit_mock.return_value = cmd.Command("success", "", b"", b"", 0) success_mock = mocker.patch("commitizen.out.success") config.settings["retry_after_failure"] = True - commands.Commit(config, {"no_retry": True})() + commit_cmd = commands.Commit(config, {"no_retry": True}) + temp_file = commit_cmd.temp_file + commit_cmd() - commit_mock.assert_called_with("feat: user created\n\ncloses #22", args="") - prompt_mock.assert_called() + commit_mock.assert_called_with("feat: user created\n\ncloses #21", args="") + prompt_mock.assert_called_once() success_mock.assert_called_once() assert not os.path.isfile(temp_file) From b42a676d1074f80bb8fab431d41f04a6b1e6317c Mon Sep 17 00:00:00 2001 From: Wei Lee Date: Sat, 30 Mar 2024 15:22:30 +0800 Subject: [PATCH 17/18] style: refine coding style based on reviews --- commitizen/commands/commit.py | 5 +++-- commitizen/cz/utils.py | 9 ++------- hooks/post-commit.py | 3 +-- 3 files changed, 6 insertions(+), 11 deletions(-) diff --git a/commitizen/commands/commit.py b/commitizen/commands/commit.py index 2489abaf29..7591a28658 100644 --- a/commitizen/commands/commit.py +++ b/commitizen/commands/commit.py @@ -1,7 +1,8 @@ +from __future__ import annotations + import contextlib import os -from typing import Optional import questionary @@ -35,7 +36,7 @@ def __init__(self, config: BaseConfig, arguments: dict): self.arguments = arguments self.temp_file: str = get_backup_file_path() - def read_backup_message(self) -> Optional[str]: + def read_backup_message(self) -> str | None: # Check the commit backup file exists if not os.path.isfile(self.temp_file): return None diff --git a/commitizen/cz/utils.py b/commitizen/cz/utils.py index d5bd63c6fc..4df2edf39c 100644 --- a/commitizen/cz/utils.py +++ b/commitizen/cz/utils.py @@ -28,10 +28,5 @@ def get_backup_file_path() -> str: else: project = project_root.as_posix().replace("/", "%") - return os.path.join( - tempfile.gettempdir(), - "cz.commit%{user}%{project}.backup".format( - user=os.environ.get("USER", ""), - project=project, - ), - ) + user = os.environ.get("USER", "") + return os.path.join(tempfile.gettempdir(), f"cz.commit%{user}%{project}.backup") diff --git a/hooks/post-commit.py b/hooks/post-commit.py index a0ad5a7749..6444e5ca84 100755 --- a/hooks/post-commit.py +++ b/hooks/post-commit.py @@ -4,8 +4,7 @@ try: from commitizen.cz.utils import get_backup_file_path except ImportError as error: - print("could not import commitizen:") - print(error) + print(f"could not import commitizen:\n{error}") exit(1) From ffb6df72be3f93ebfecdd94b74c43ba429157f1a Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Sat, 30 Mar 2024 07:58:00 +0000 Subject: [PATCH 18/18] =?UTF-8?q?bump:=20version=203.20.0=20=E2=86=92=203.?= =?UTF-8?q?21.0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .pre-commit-config.yaml | 2 +- CHANGELOG.md | 14 ++++++++++++++ commitizen/__version__.py | 2 +- pyproject.toml | 4 ++-- 4 files changed, 18 insertions(+), 4 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index fb3881cc7a..d66d4eb558 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -46,7 +46,7 @@ repos: exclude: "poetry.lock" - repo: https://github.com/commitizen-tools/commitizen - rev: v3.20.0 # automatically updated by Commitizen + rev: v3.21.0 # automatically updated by Commitizen hooks: - id: commitizen - id: commitizen-branch diff --git a/CHANGELOG.md b/CHANGELOG.md index 38f588354c..83cb977b2c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,17 @@ +## v3.21.0 (2024-03-30) + +### Feat + +- **commit**: add retry_after_failure config option and --no-retry flag + +### Refactor + +- **utils**: convert git project root to posix path for backup file name +- **commit**: use Optional[str] instead of str | None +- **commit**: remove unused tempfile import +- **git-hooks**: make git hooks use get_backup_file_path +- **utils**: move backup path creation to utils + ## v3.20.0 (2024-03-19) ### Feat diff --git a/commitizen/__version__.py b/commitizen/__version__.py index 10c5c0dd1b..f87b7d84cf 100644 --- a/commitizen/__version__.py +++ b/commitizen/__version__.py @@ -1 +1 @@ -__version__ = "3.20.0" +__version__ = "3.21.0" diff --git a/pyproject.toml b/pyproject.toml index 82f415ff34..310c80eedc 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,5 +1,5 @@ [tool.commitizen] -version = "3.20.0" +version = "3.21.0" tag_format = "v$version" version_files = [ "pyproject.toml:version", @@ -9,7 +9,7 @@ version_files = [ [tool.poetry] name = "commitizen" -version = "3.20.0" +version = "3.21.0" description = "Python commitizen client tool" authors = ["Santiago Fraire "] license = "MIT"