From 105e8a8111e6b2b3e5cbbdeeb2f499b967f97628 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pedro=20J=2E=20Est=C3=A9banez?= Date: Tue, 30 Aug 2022 12:18:58 +0200 Subject: [PATCH] Add ability to extend the set of Git pre-commit hooks (cherry picked from commit 8e2d0e1bb16409ad2e32e6e59432ffafb03c14ee) --- .gitignore | 1 + misc/hooks/README.md | 5 +++++ misc/hooks/pre-commit | 2 +- 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 0ef640bd2f1..539003ca6b9 100644 --- a/.gitignore +++ b/.gitignore @@ -23,6 +23,7 @@ ########################### /custom.py +misc/hooks/pre-commit-custom-* ############################# ### Godot generated files ### diff --git a/misc/hooks/README.md b/misc/hooks/README.md index e420c6cb5c3..f9cf32f4c5a 100644 --- a/misc/hooks/README.md +++ b/misc/hooks/README.md @@ -35,3 +35,8 @@ so they should work out of the box on Linux/macOS. ##### black - Python installation: make sure Python is added to the `PATH` - Install `black` - in any console: `pip3 install black` + +## Custom hooks + +The pre-commit hook will run any other script in `.git/hooks` whose filename +matches `pre-commit-custom-*`, after the Godot ones. diff --git a/misc/hooks/pre-commit b/misc/hooks/pre-commit index ab0fc8176fe..63591612607 100755 --- a/misc/hooks/pre-commit +++ b/misc/hooks/pre-commit @@ -13,8 +13,8 @@ # pre-commit hooks to be executed. They should be in the same .git/hooks/ folder # as this script. Hooks should return 0 if successful and nonzero to cancel the # commit. They are executed in the order in which they are listed. -#HOOKS="pre-commit-compile pre-commit-uncrustify" HOOKS="pre-commit-clang-format pre-commit-black pre-commit-make-rst" +HOOKS="$HOOKS $(find $(dirname -- "$0") -type f -name 'pre-commit-custom-*' -exec basename {} \;)" ########################################################### # There should be no need to change anything below this line.