Skip to content

Instantly share code, notes, and snippets.

@SJShaw
Created November 9, 2023 09:54
Show Gist options
  • Save SJShaw/dd0e89d25dcbbb59a9be1d45382ddbb5 to your computer and use it in GitHub Desktop.
Save SJShaw/dd0e89d25dcbbb59a9be1d45382ddbb5 to your computer and use it in GitHub Desktop.
MIBiG JSON commit hook
#!/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