Last active
August 29, 2015 13:58
-
-
Save hobnob/10393263 to your computer and use it in GitHub Desktop.
Git Hooks
This file contains 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 | |
echo " $(tput setaf 1)" && | |
git branch --merged master | grep -v master | xargs --no-run-if-empty git branch -d && | |
echo " $(tput sgr0)" |
This file contains 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 | |
# git pre-commit hook | |
# Modified from https://gist.github.com/skwashd/8572382 | |
set -e | |
ROOT_DIR=$(git rev-parse --show-toplevel) | |
autofix=$(git config --bool hooks.autofix) | |
for file in $(git diff --cached --name-only --diff-filter=ACM); do | |
# Skip docs | |
if [[ $file =~ (README.*|LICENSE) ]]; then | |
continue; | |
fi | |
echo "Cheking $file"; | |
ext="${file##*.}" | |
case "$ext" in "php") | |
if [ "$autofix" == "true" ]; then | |
php-cs-fixer fix "$ROOT_DIR/$file" | |
git add "$ROOT_DIR/$file" | |
else | |
php-cs-fixer fix "$ROOT_DIR/$file" --dry-run | |
fi | |
php -l "$ROOT_DIR/$file" | |
;; | |
esac | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment