Commit 5c807d42 authored by David Spencer's avatar David Spencer

hooks/pre-commit: Review changes :)

Thanks to Urchlay, dive, and shellcheck.net :p
parent 3afa3395
......@@ -47,30 +47,29 @@
ERROR="no"
FILES=$(git diff-index --cached --name-only HEAD)
HAS_INFO=$(git diff-index --cached --name-only HEAD | grep "\.info")
DIR=""
if ! [ -z "$FILES" ]; then
if [ -n "$FILES" ]; then
for i in $FILES; do
if [ -e $i ]; then
if [ -e "$i" ]; then
MODE=$(stat -c "%a" "$i")
if ! [ $MODE = "644" ]; then
if ! [ "$MODE" = "644" ]; then
echo "$i has wrong mode set ($MODE instead of 644)"
ERROR="yes"
fi
fi
if [ "${i##*.}" = "info" ]; then
if ! msg=$( . $i 2>&1 ); then
echo "$msg"
if [ "${i##*.}" = "info" ]; then
if ! msg=$( . "$i" 2>&1 ); then
echo "$msg"
ERROR="yes"
fi
fi
if [ -z "$DIR" ]; then
DIR=$(dirname "$i")
elif [ "$DIR" != "$(dirname "$i")" ]; then
echo "Please don't commit in multiple directories"
ERROR="yes"
fi
fi
if [ -z "$DIR" ]; then
DIR=$(dirname $i)
elif [ "$DIR" != "$(dirname $i)" ]; then
echo "Don't commit in multiple directories"
ERROR="yes"
fi
done
fi
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment