Skip to content

Instantly share code, notes, and snippets.

@Newky
Created May 21, 2013 21:40
Show Gist options
  • Save Newky/5623479 to your computer and use it in GitHub Desktop.
Save Newky/5623479 to your computer and use it in GitHub Desktop.
Json git hook for write up
import json
def precommit(git_state):
for fname in git_state["files"]:
if fname.endswith(".json"):
with open(fname, "r") as f:
try:
json.loads(f.read())
continue
except ValueError, e:
print "Invalid json in %s:" % fname
print e.message
return False
return True
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment