diff options
Diffstat (limited to 'misc/hooks')
-rw-r--r-- | misc/hooks/README.md | 5 | ||||
-rwxr-xr-x | misc/hooks/pre-commit | 2 | ||||
-rwxr-xr-x | misc/hooks/pre-commit-black | 4 | ||||
-rwxr-xr-x | misc/hooks/pre-commit-clang-format | 4 |
4 files changed, 10 insertions, 5 deletions
diff --git a/misc/hooks/README.md b/misc/hooks/README.md index 8732237244..ea94b3f5f3 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 ab0fc8176f..6359161260 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. diff --git a/misc/hooks/pre-commit-black b/misc/hooks/pre-commit-black index fd93bfe73c..b7335685ae 100755 --- a/misc/hooks/pre-commit-black +++ b/misc/hooks/pre-commit-black @@ -70,7 +70,7 @@ if [ ! -x "$BLACK" ] ; then $XMSG -center -title "Error" "Error: black executable not found." exit 1 elif [ \( \( "$OSTYPE" = "msys" \) -o \( "$OSTYPE" = "win32" \) \) -a \( -x "$PWSH" \) ]; then - winmessage="$(canonicalize_filename "./.git/hooks/winmessage.ps1")" + winmessage="$(canonicalize_filename "$(dirname -- "$0")/winmessage.ps1")" $PWSH -noprofile -executionpolicy bypass -file "$winmessage" -center -title "Error" --text "Error: black executable not found." exit 1 fi @@ -160,7 +160,7 @@ while true; do yn="N" fi elif [ \( \( "$OSTYPE" = "msys" \) -o \( "$OSTYPE" = "win32" \) \) -a \( -x "$PWSH" \) ]; then - winmessage="$(canonicalize_filename "./.git/hooks/winmessage.ps1")" + winmessage="$(canonicalize_filename "$(dirname -- "$0")/winmessage.ps1")" $PWSH -noprofile -executionpolicy bypass -file "$winmessage" -file "$patch" -buttons "Apply":100,"Apply and stage":200,"Do not apply":0 -center -default "Do not apply" -geometry 800x600 -title "Do you want to apply that patch?" choice=$? if [ "$choice" = "100" ] ; then diff --git a/misc/hooks/pre-commit-clang-format b/misc/hooks/pre-commit-clang-format index e8e62e6470..44b6f59132 100755 --- a/misc/hooks/pre-commit-clang-format +++ b/misc/hooks/pre-commit-clang-format @@ -90,7 +90,7 @@ if [ ! -x "$CLANG_FORMAT" ] ; then $XMSG -center -title "Error" "$message" exit 1 elif [ \( \( "$OSTYPE" = "msys" \) -o \( "$OSTYPE" = "win32" \) \) -a \( -x "$PWSH" \) ]; then - winmessage="$(canonicalize_filename "./.git/hooks/winmessage.ps1")" + winmessage="$(canonicalize_filename "$(dirname -- "$0")/winmessage.ps1")" $PWSH -noprofile -executionpolicy bypass -file "$winmessage" -center -title "Error" --text "$message" exit 1 fi @@ -200,7 +200,7 @@ while true; do yn="N" fi elif [ \( \( "$OSTYPE" = "msys" \) -o \( "$OSTYPE" = "win32" \) \) -a \( -x "$PWSH" \) ]; then - winmessage="$(canonicalize_filename "./.git/hooks/winmessage.ps1")" + winmessage="$(canonicalize_filename "$(dirname -- "$0")/winmessage.ps1")" $PWSH -noprofile -executionpolicy bypass -file "$winmessage" -file "$patch" -buttons "Apply":100,"Apply and stage":200,"Do not apply":0 -center -default "Do not apply" -geometry 800x600 -title "Do you want to apply that patch?" choice=$? if [ "$choice" = "100" ] ; then |