Last active
August 29, 2015 13:57
-
-
Save alea12/9546352 to your computer and use it in GitHub Desktop.
hooks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/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