Created
November 9, 2023 09:54
-
-
Save SJShaw/dd0e89d25dcbbb59a9be1d45382ddbb5 to your computer and use it in GitHub Desktop.
MIBiG JSON commit hook
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/bash | |
for line in `git diff --cached --name-only --diff-filter=ACM | grep -v retired | grep -e json`; do | |
if [[ "$line" != *.json ]] ; then | |
continue | |
fi | |
test `tail -c 1 $line` | |
if [ "$?" == "1" ] ; then | |
truncate -s -1 $line | |
echo "Aborting commit due to trailing newline; add changes and recommit" | |
exit 1 | |
fi | |
if [[ "$line" != *BGC*.json ]] ; then | |
continue | |
fi | |
python scripts/check_valid.py $line | |
if [ "$?" == "1" ] ; then | |
echo "Aborting commit due to invalid JSON: $line" | |
exit 1 | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment