From 09ba070b7e7a6ec9a7e7fcfcf5f3ef0d95752149 Mon Sep 17 00:00:00 2001 From: Frantisek Hrbata Date: Tue, 19 Dec 2023 09:35:26 +0100 Subject: [PATCH] fix: allow to use older pre-commit hook version With b93cc581a5d6 ("fix: set default pre-commit hook stages to pre-commit..") a dependency on pre-commit 3.3 was added. As it turned out, there are people still using e.g. 2.16 version and this change is causing problems. 1. The minimum_pre_commit_version is checked after the config is parsed. Meaning if there is a problem in the config file, like unknown pre-commit for default_stages, pre-commit exits with an error not suggesting that it should be updated. 2. "pre-commit" was added in 3.2 for consistency with git hook names and we can use "commit" instead avoiding dependency on newer pre-commit. For more info please see [1] and [2]. 3. default_install_hook_types[4] were added in 2.18.0[3]. This was IMHO actually a nice feature to have in our .pre-commit-config.yaml, because it specifies which hooks should be installed when pre-commit install is executed. Meaning it's not necessary to list the stages explicitly with the -t options. Anyway we haven't used this feature till now, so it hopefully should not be a problem if we remove it again. With this change we can still avoid to start pre-commit plugins multiple times for different stages, but also make it compatible with older versions(2.16). [1] https://github.com/pre-commit/pre-commit/issues/2732 [2] https://github.com/pre-commit/pre-commit/pull/2808 [3] https://github.com/pre-commit/pre-commit/blob/main/CHANGELOG.md#2180---2022-04-02 [4] https://pre-commit.com/#top_level-default_install_hook_types Fixes: b93cc581a5d6 ("fix: set default pre-commit hook stages to pre-commit..") Signed-off-by: Frantisek Hrbata --- .pre-commit-config.yaml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 0e2ac147c4..d4621b27c2 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,9 +1,7 @@ # See https://pre-commit.com for more information # See https://pre-commit.com/hooks.html for more hooks -minimum_pre_commit_version: 3.3.0 -default_install_hook_types: [pre-commit, post-commit, commit-msg] -default_stages: [pre-commit] +default_stages: [commit] repos: - repo: https://github.com/pre-commit/pre-commit-hooks