diff options
author | Aarni Koskela <akx@iki.fi> | 2024-01-09 14:47:16 +0200 |
---|---|---|
committer | Rémi Verschelde <rverschelde@gmail.com> | 2024-02-26 14:57:53 +0100 |
commit | 20c563de40923d3333301ca8ed1f3f213a67ea17 (patch) | |
tree | 9da6a86399de77c74aba91e3d48b408b0a8516c2 /misc/hooks/pre-commit | |
parent | bb6b06c81343073f10cbbd2af515cf0dac1e6549 (diff) | |
download | redot-engine-20c563de40923d3333301ca8ed1f3f213a67ea17.tar.gz |
Replace hand-written pre-commit hooks with `pre-commit` Python tool
`pre-commit` can be installed with pip, and configured in the Godot repo with
`pre-commit install`. It can then easily be run both locally with
`pre-commit run`, and on CI, in a cross-platform way.
This makes it much easier for contributors to set up pre-commit hooks,
without having to manually copy files to their git folder.
Co-authored-by: Rémi Verschelde <rverschelde@gmail.com>
Diffstat (limited to 'misc/hooks/pre-commit')
-rwxr-xr-x | misc/hooks/pre-commit | 50 |
1 files changed, 0 insertions, 50 deletions
diff --git a/misc/hooks/pre-commit b/misc/hooks/pre-commit deleted file mode 100755 index 6359161260..0000000000 --- a/misc/hooks/pre-commit +++ /dev/null @@ -1,50 +0,0 @@ -#!/bin/sh -# Git pre-commit hook that runs multiple hooks specified in $HOOKS. -# Make sure this script is executable. Bypass hooks with git commit --no-verify. - -# This file is part of a set of unofficial pre-commit hooks available -# at github. -# Link: https://github.com/githubbrowser/Pre-commit-hooks -# Contact: David Martin, david.martin.mailbox@googlemail.com - - -########################################################### -# CONFIGURATION: -# 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-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. - -. "$(dirname -- "$0")/canonicalize_filename.sh" - -# exit on error -set -e - -# Absolute path to this script, e.g. /home/user/bin/foo.sh -SCRIPT="$(canonicalize_filename "$0")" - -# Absolute path this script is in, thus /home/user/bin -SCRIPTPATH="$(dirname -- "$SCRIPT")" - - -for hook in $HOOKS -do - echo "Running hook: $hook" - # run hook if it exists - # if it returns with nonzero exit with 1 and thus abort the commit - if [ -f "$SCRIPTPATH/$hook" ]; then - "$SCRIPTPATH/$hook" - if [ $? != 0 ]; then - exit 1 - fi - else - echo "Error: file $hook not found." - echo "Aborting commit. Make sure the hook is in $SCRIPTPATH and executable." - echo "You can disable it by removing it from the list in $SCRIPT." - echo "You can skip all pre-commit hooks with --no-verify (not recommended)." - exit 1 - fi -done |