Updating & documenting hooks
This commit is contained in:
parent
dac8563a32
commit
87f907d948
8
Hooks/scripts.d/local-hooks
Executable file
8
Hooks/scripts.d/local-hooks
Executable file
@ -0,0 +1,8 @@
|
||||
# This script ensures that repos can commit personal hooks in the ./precommit-hooks folder.
|
||||
|
||||
for script in `find precommit-hooks -type f`; do
|
||||
if ! bash "$script"; then
|
||||
echo "Local script $script failed checks."
|
||||
exit 1
|
||||
fi
|
||||
done
|
@ -8,4 +8,6 @@ elif [ -f requirements.txt ]; then
|
||||
python3 -m venv venv
|
||||
venv/bin/python3 -m pip install -r requirements.txt
|
||||
fi
|
||||
if [ -d tests/ ]; then
|
||||
python3 -m pytest
|
||||
fi
|
||||
|
@ -2,6 +2,11 @@
|
||||
|
||||
# Sourced from https://github.com/git/git/blob/master/templates/hooks--pre-commit.sample
|
||||
|
||||
if git ls-files | xargs egrep -irl '\s\+$' ; then
|
||||
echo The above lines have trailing whitespace. Run "sed -i 's/\s\+$//'" on the affected files.
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if git rev-parse --verify HEAD >/dev/null 2>&1
|
||||
then
|
||||
against=HEAD
|
||||
@ -13,9 +18,6 @@ fi
|
||||
# Redirect output to stderr.
|
||||
exec 1>&2
|
||||
|
||||
|
||||
# If there are whitespace errors, print the offending file names and fail.
|
||||
git diff-index --check --cached $against --
|
||||
if [ $? -ne 0 ]; then
|
||||
echo The above lines have trailing whitespace. Run "sed -i 's/\s\+$//'" on the affected files.
|
||||
exit 1
|
||||
fi
|
||||
exec git diff-index --check --cached $against --
|
||||
|
@ -12,3 +12,9 @@ The following executables are available:
|
||||
|
||||
* `uniglot-clone` ensures that when repos are cloned, they are attached to the standard Uniglot hooks.
|
||||
* `home-git` is support for [User Support Repositories](https://aninix.net/AniNIX/Wiki/src/branch/main/Articles/User_Support_Repositories.md).
|
||||
|
||||
# Hooks
|
||||
|
||||
The Hooks folder includes a standard pre-commit and pre-receive that will be enforced across repos. These pre-commit and pre-receive will enforce the contents of `Hooks/scripts.d`. This allows us to enforce standards of quality across the ecosystem.
|
||||
|
||||
Notably, each repo that subscribes to this enforcement can also commit their own standards in addition to global standards. Python tests should go in a folder called `tests/` and scripts in a folder called `precommit-hooks/`. These will be run in addition to the global hooks.
|
||||
|
Loading…
Reference in New Issue
Block a user