Skip to content

Instantly share code, notes, and snippets.

@Upliner
Created May 21, 2018 13:54
Show Gist options
  • Save Upliner/6480e6b91747135db45fdccf56b7e50e to your computer and use it in GitHub Desktop.
Save Upliner/6480e6b91747135db45fdccf56b7e50e to your computer and use it in GitHub Desktop.
The git hook that checks validity of .json files in the repository
#!/bin/bash
exec 1>&2
git diff --cached --name-only --diff-filter=d -z HEAD | while IFS= read -r -d '' file ; do
if [ "${file##*.}" = "json" ]; then
if ! cat $file | python -m json.tool > /dev/null; then
echo $file
exit 1
fi
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment