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 #!/bin/sh -e
export RUN_BIN="$0" RUN_BIN="$0"
export RUN_DIR=$(dirname "$(realpath "$0")") RUN_DIR=$(dirname "$(realpath "$0")")
task= export RUN_BIN
if [ -e "$RUN_DIR/scripts/$1" ]; then export RUN_DIR
if [ "$(dirname "$0")" = ".git/hooks" ]; then
task=$(basename "$0")
else
task="$1" task="$1"
elif [ -e "$RUN_DIR/scripts/local/$1" ]; then [ $# -gt 0 ] && shift
task="local/$1"
fi 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 [ -z "$script" ] && exit 1
exec "$RUN_DIR/scripts/$task" "$@"
exec "$RUN_DIR/scripts/$script" "$@"

View file

@ -0,0 +1 @@
../lint