add pre-commit git hook (run lint)

This commit is contained in:
ducklet 2020-11-12 23:45:20 +01:00
parent 87a4daf5c6
commit 7484584fae
2 changed files with 21 additions and 9 deletions

29
run
View file

@ -1,16 +1,27 @@
#!/bin/sh -e
export RUN_BIN="$0"
export RUN_DIR=$(dirname "$(realpath "$0")")
RUN_BIN="$0"
RUN_DIR=$(dirname "$(realpath "$0")")
task=
if [ -e "$RUN_DIR/scripts/$1" ]; then
export RUN_BIN
export RUN_DIR
if [ "$(dirname "$0")" = ".git/hooks" ]; then
task=$(basename "$0")
else
task="$1"
elif [ -e "$RUN_DIR/scripts/local/$1" ]; then
task="local/$1"
[ $# -gt 0 ] && shift
fi
[ -z "$task" ] && exit 1
script=
if [ -x "$RUN_DIR/scripts/local/$task" ]; then
script="local/$task"
elif [ -x "$RUN_DIR/scripts/git-hooks/$task" ]; then
script="git-hooks/$task"
elif [ -x "$RUN_DIR/scripts/$task" ]; then
script="$task"
fi
shift
exec "$RUN_DIR/scripts/$task" "$@"
[ -z "$script" ] && exit 1
exec "$RUN_DIR/scripts/$script" "$@"