2014-10-26 13:47:12 +00:00
|
|
|
#!/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 inspired by 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
|
|
|
|
|
|
|
|
|
|
|
|
###########################################################
|
|
|
|
# SETTINGS:
|
|
|
|
# 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.
|
|
|
|
###########################################################
|
|
|
|
|
2021-09-24 18:11:13 +00:00
|
|
|
HOOKS="scripts/git-hooks/pre-commit.hook scripts/git-hooks/pre-commit-python.hook"
|
2014-10-26 13:47:12 +00:00
|
|
|
|
|
|
|
# exit on error
|
|
|
|
set -e
|
|
|
|
|
2021-10-01 19:49:12 +00:00
|
|
|
if [ "$GST_DISABLE_PRE_COMMIT_HOOKS" = "1" ]
|
|
|
|
then
|
|
|
|
echo "Pre-commits hooks disabled by env GST_DISABLE_PRE_COMMIT_HOOKS."
|
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
|
2014-10-26 13:47:12 +00:00
|
|
|
echo $PWD
|
|
|
|
|
|
|
|
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 "$PWD/$hook" ]; then
|
|
|
|
"$PWD/$hook"
|
|
|
|
if [ $? != 0 ]; then
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
else
|
|
|
|
echo "Error: file $hook not found."
|
|
|
|
echo "Aborting commit. Make sure the hook is at $PWD/$hook and executable."
|
|
|
|
echo "You can disable it by removing it from the list"
|
|
|
|
echo "You can skip all pre-commit hooks with --no-verify (not recommended)."
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
|