0
0
mirror of https://github.com/letic/Shell-Scripts.git synced 2024-09-28 05:56:04 +00:00
AWS_Shell-Scripts/hooks/pre-commit-rubocop

26 lines
542 B
Plaintext
Raw Normal View History

2016-04-01 19:02:51 +00:00
#!/bin/sh
#
# 1. Rename to pre-commit
# 2. Copy to .git/hooks/pre-commit
docker ps 2> /dev/null
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:04 +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