Skip to content

Instantly share code, notes, and snippets.

@alea12
Last active August 29, 2015 13:57
Show Gist options
  • Save alea12/9546352 to your computer and use it in GitHub Desktop.
Save alea12/9546352 to your computer and use it in GitHub Desktop.
hooks
#!/bin/sh
# Check whether commit message includes issue ID
exp="(?:close|closed|closes|fix|fixed|fixes|addresses|references|refs|re|see)"
exp=$exp".?(#[0-9]+(?:(?:[, &]+| *and *)#[0-9]+)*)"
grep -E "$exp" $1 > /dev/null
if [ $? -ne 0 ]; then
echo '*** ERROR ***'
echo 'You need to specify an issue ID to commit.'
exit 1
fi
#!/bin/sh
if git rev-parse --verify HEAD >/dev/null 2>&1
then
against=HEAD
else
# Initial commit: diff against an empty tree object
against=4b825dc642cb6eb9a060e54bf8d69288fbee4904
fi
# Redirect output to stderr.
exec 1>&2
IS_ERROR=0
# コミットされるファイルのうち、.phpで終わるもの
for FILE in `git diff-index --name-status $against -- | grep -E '^[AUM].*\.php$'| cut -c3-`; do
# シンタックスのチェック
if php -l $FILE; then
continue
else
echo '*** ERROR ***'
IS_ERROR=1
fi
done
exit $IS_ERROR
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment