Refacot & improve git pre-commit hook
This commit is contained in:
parent
db110afdae
commit
a6be7b1e30
1 changed files with 18 additions and 17 deletions
|
@ -26,34 +26,21 @@ git checkout-index --prefix="$temp/index/" --all
|
||||||
|
|
||||||
cd $temp/index/
|
cd $temp/index/
|
||||||
|
|
||||||
|
ln -s "$WORK_DIR"/.git/ .git
|
||||||
if [ -n "$filter" ]; then
|
if [ -n "$filter" ]; then
|
||||||
ln -s "$WORK_DIR"/.git/ .git
|
|
||||||
sh -c "$filter"
|
sh -c "$filter"
|
||||||
git add --all
|
git add --all
|
||||||
rm .git
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ -n "$validate" ]; then
|
|
||||||
/bin/echo -e "\x1b[33mValidating commit\x1b[0m"
|
|
||||||
/bin/echo -e "\x1b[2mλ $validate\x1b[0m"
|
|
||||||
if sh -c "$validate"
|
|
||||||
then
|
|
||||||
/bin/echo -e "\x1b[32mValidation Passed!\x1b[0m"
|
|
||||||
else
|
|
||||||
error=1
|
|
||||||
/bin/echo -e "\x1b[1;31mValidation Failed!\x1b[0m"
|
|
||||||
fi
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
case $indentation in
|
case $indentation in
|
||||||
tab|tabs)
|
tab|tabs)
|
||||||
/bin/echo -e "\x1b[2mChecking tab indentation"
|
/bin/echo -e "\x1b[2mChecking indentation: \x1b[32mtabs"
|
||||||
for file in $(new); do
|
for file in $(new); do
|
||||||
check '\t' $file || error=1
|
check '\t' $file || error=1
|
||||||
done
|
done
|
||||||
;;
|
;;
|
||||||
space|spaces)
|
space|spaces)
|
||||||
/bin/echo -e "\x1b[2mChecking space indentation"
|
/bin/echo -e "\x1b[2mChecking indentation: \x1b[32mspaces"
|
||||||
for file in $(new); do
|
for file in $(new); do
|
||||||
check ' ' $file || error=1
|
check ' ' $file || error=1
|
||||||
done
|
done
|
||||||
|
@ -67,11 +54,25 @@ case $indentation in
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
|
if [ -n "$validate" ]; then
|
||||||
|
/bin/echo -e "\x1b[33mValidating commit\x1b[0m"
|
||||||
|
/bin/echo -e "\x1b[2mλ $validate\x1b[0m"
|
||||||
|
# if sh -c "$validate"
|
||||||
|
# then
|
||||||
|
# /bin/echo -e "\x1b[32mValidation Passed!\x1b[0m"
|
||||||
|
# else
|
||||||
|
# error=1
|
||||||
|
# /bin/echo -e "\x1b[1;31mValidation Failed!\x1b[0m"
|
||||||
|
# fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
rm .git
|
||||||
|
|
||||||
if [ -n "$error" ]
|
if [ -n "$error" ]
|
||||||
then exit 1
|
then exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
cd "$WORK_DIR"/.git
|
cd "$WORK_DIR"
|
||||||
rm -rf $temp
|
rm -rf $temp
|
||||||
|
|
||||||
hook=$(basename $0)
|
hook=$(basename $0)
|
||||||
|
|
Loading…
Reference in a new issue