Commit f080d23c by jarv

Merge pull request #7 from edx/jrbl/feature/json_lint_hooks

Adding pre-commit and post-checkout hooks
parents 53634843 52fb2492
......@@ -114,6 +114,7 @@ cloudformation_templates <-- official edX cloudformation templates
```
mkvirtualenv ansible
pip install -r ansible-requirements.txt
util/sync_hooks.sh
```
### Launching example cloudformation stack - Working example
......
#!/bin/sh
dir=`git rev-parse --show-toplevel`
if [ -z $dir ]; then
exit 1
fi
echo -n Setting up hooks from git-hooks..
$dir/util/sync_hooks.sh >/dev/null
if [ $? -eq 0 ]; then
echo . done.
else
exit 1
fi
#!/bin/sh
dir=`git rev-parse --show-toplevel`
if [ -z $dir ]; then
exit 1
fi
echo -n Checking JSON parses..
$dir/util/json_lint.sh
if [ $? -eq 0 ]; then
echo . it does!
else
exit 1
fi
#!/bin/bash
# A very simple check to see if the json files in the project at least compile.
# If they do not, a cryptic message that might be helpful is produced.
# Save current directory so we can come back; change to repo root
STARTED_FROM=`pwd`
cd $(git rev-parse --show-toplevel)
# Do very basic syntax check of every json file to make sure it's valid format
for file in `find . -iname '*.json'`; do
cat $file | python -m json.tool 1>/dev/null 2>json_complaint.err;
retval=$?
if [ $retval != 0 ]; then
echo "JSON errors in $file"
cat json_complaint.err
rm -f json_complaint.err
cd $STARTED_FROM
exit $retval;
fi
done
# Everything went ok!
rm -f json_complaint.err
cd $STARTED_FROM
exit 0
#!/bin/bash
# A small utility to symlink the files from git-hooks/ with filenames ending
# like .in into the directory .git/hooks/
#
# It's intended this be run once near the start of a project by hand, and then
# subsequently a hook that it installs keeps it running at project checkouts.
# Save current directory so we can come back; change to repo root
STARTED_FROM=`pwd`
cd $(git rev-parse --show-toplevel)
# Sync git-hooks directory entries into .git/hooks/
for file in git-hooks/*.in; do
filepart=`basename $file .in`
if [ -e .git/hooks/$filepart -a ! -L .git/hooks/$filepart ]; then
echo ".git/hooks/$filepart not link-managed; bailing..."
echo "please examine your .git/hooks/ directory and repair inconsistencies manually"
cd $STARTED_FROM
exit 1
else
ln -v -s -b -f `pwd`/$file .git/hooks/$filepart
fi
done
# Ok, everything went well; restore previous context
cd $STARTED_FROM
exit 0
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment