based on blueicefield's pre-receive hook
Usage: Place pre-receive file in /central_git_repo/hooks/ and make it executable
based on blueicefield's pre-receive hook
Usage: Place pre-receive file in /central_git_repo/hooks/ and make it executable
#!/bin/bash | |
COMMAND="php -l " | |
TEMPDIR=`mktemp -d` | |
RED="\e[1;31m" | |
NONE="\e[m" | |
while read oldrev newrev refname; do | |
files=`git diff --name-only ${oldrev} ${newrev}` | |
for file in ${files}; do | |
object=`git ls-tree --full-name -r ${newrev} | egrep "(\s)${file}\$" | awk '{ print $3 }'` | |
if [ -z ${object} ]; then continue; fi | |
mkdir -p "${TEMPDIR}/`dirname ${file}`" &> /dev/null | |
git cat-file blob ${object} > ${TEMPDIR}/${file} | |
done; | |
done; | |
cd ${TEMPDIR} | |
for i in * | |
do | |
echo -e "${RED}" | |
${COMMAND} $i | |
STATUS=$? | |
echo -e "${NONE}" | |
if [ $STATUS -ne 0 ] | |
then | |
exit ${STATUS} | |
fi | |
done; | |
rm -rf ${TEMPDIR} &> /dev/null | |
exit ${STATUS} |