Skip to content

Instantly share code, notes, and snippets.

@hobnob
Last active August 29, 2015 13:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hobnob/10393263 to your computer and use it in GitHub Desktop.
Save hobnob/10393263 to your computer and use it in GitHub Desktop.
Git Hooks
#!/bin/sh
echo " $(tput setaf 1)" &&
git branch --merged master | grep -v master | xargs --no-run-if-empty git branch -d &&
echo " $(tput sgr0)"
#!/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