Skip to content

Instantly share code, notes, and snippets.

@handrus
Forked from skwashd/pre-commit
Last active August 29, 2015 13:56
Show Gist options
  • Save handrus/9254534 to your computer and use it in GitHub Desktop.
Save handrus/9254534 to your computer and use it in GitHub Desktop.
#!/bin/bash
#
# Git pre-commit hook for Drupal projects.
# Created by Dave Hall - http://davehall.com.au
#
# Changed by Handrus Nogueira and Luiz Petri
#
# Distributed under the terms of the WTFPL - http://www.wtfpl.net/
#
set -e
files = ""
ROOT_DIR=$(git rev-parse --show-toplevel)
for file in $(git diff --cached --name-only --diff-filter=ACM); do
files = "$files $ROOT_DIR/$file"
# Skip docs
ext="${file##*.}"
if ! [[ $ext in ("php" | "module" | "inc") ]]; then
continue;
fi
php -l "$ROOT_DIR/$file"
done
echo "Running coder";
drush coder-review --minor --comment --i18n --release --security --sql --style --no-empty "$files"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment