2016-04-01 19:02:51 +00:00
|
|
|
#!/bin/sh
|
|
|
|
#
|
|
|
|
# 1. Rename to pre-commit
|
|
|
|
# 2. Copy to .git/hooks/pre-commit
|
|
|
|
|
2016-04-06 11:38:53 +00:00
|
|
|
docker ps 1> /dev/null 2>&1
|
2016-04-01 19:02:51 +00:00
|
|
|
|
|
|
|
if [ $? -ne 0 ]; then
|
|
|
|
echo "Check that docker is running correctly"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
app="$(git rev-parse --show-toplevel)/src"
|
|
|
|
|
|
|
|
errors=$(\
|
|
|
|
docker run \
|
|
|
|
--cpu-shares 1024 \
|
|
|
|
--rm=true \
|
|
|
|
--volume $app:/app \
|
2016-04-01 20:16:55 +00:00
|
|
|
bbcnews/rubocop-config --format simple --fail-level F 2> /dev/null | grep '^F:' | wc -l | tr -d '[[:space:]]')
|
2016-04-01 19:02:51 +00:00
|
|
|
|
|
|
|
if [ $errors -gt 0 ]; then
|
2016-04-01 19:09:03 +00:00
|
|
|
echo "Rubocop reported $errors errors. Please double check your code"
|
2016-04-01 19:02:51 +00:00
|
|
|
exit 1
|
|
|
|
fi
|