update pre-commit
This commit is contained in:
@@ -1,16 +1,24 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
#
|
#
|
||||||
# Run pre commit checks on bin/yait. Requires `shellcheck` as well as a POSIX
|
# Run pre-commit checks on bin/yait. Requires `shellcheck` and a POSIX
|
||||||
# shell (duh)
|
# shell (duh).
|
||||||
|
|
||||||
|
me=$(basename "$0")
|
||||||
|
|
||||||
|
fmt() {
|
||||||
|
echo "${me}[$$]: $*"
|
||||||
|
}
|
||||||
|
|
||||||
script_path="./bin/yait"
|
script_path="./bin/yait"
|
||||||
|
|
||||||
if git diff --cached --name-only | grep -q "$script_path"; then
|
if git diff --cached --name-only | grep -q "$script_path"; then
|
||||||
if ! shellcheck "$script_path"; then
|
if shellcheck --enable=all --shell=sh "$script_path"; then
|
||||||
echo "[$0]: Syntax errors found in $script_path. Commit aborted."
|
fmt "All tests passed."
|
||||||
|
exit 0
|
||||||
|
else
|
||||||
|
fmt "Syntax errors found in $script_path. Commit aborted."
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "[$0] All Tests Pass"
|
|
||||||
exit 0
|
exit 0
|
||||||
|
|||||||
Reference in New Issue
Block a user