Last active
December 31, 2015 20:08
-
-
Save drewdhunter/8037753 to your computer and use it in GitHub Desktop.
Pre commit hook useful for Magento projects
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
#!/usr/bin/env bash | |
set -eu | |
declare -a file_patterns=('app/code/core' 'app/Mage.php$' '^index.php$') | |
exit_status=0 | |
while read x file; do | |
for file_pattern in ${file_patterns[@]}; do | |
if [[ $file =~ $file_pattern ]]; then | |
echo "Core change detected: $file" >&2 | |
exit_status=1 | |
fi | |
done | |
done < <(git diff --cached --name-status) | |
exit $exit_status; |
Nice one!
Remember that patches are okay ;)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You should make the following change to the code.
If you only look at index you will get false negatives.
In my case it found error with file Model/Source/Noindex.php
See my fork at https://gist.github.com/freestream/8954807