#!/bin/sh

# get changed .php files, ready to be commited, all but deleted
FILES=$(git diff --name-only --cached --diff-filter=ACMRTUXB | grep .php);

# run phpcs
if [ ! -z "$FILES" ]; then
	printf "Running Code Sniffer..."
	vendor/bin/phpcs $FILES --standard=vendor/dtforce/coding-standard/src/DTForceCodingStandard/ruleset.xml

	if [ $? -ne 0 ]
	then
		printf "\033[0;41;37mFix coding standards before commit!\033[0m\n"
		exit 1
	fi
fi
