mirror of
https://github.com/letic/Shell-Scripts.git
synced 2024-09-28 05:56:04 +00:00
26 lines
548 B
Bash
26 lines
548 B
Bash
#!/bin/sh
|
|
#
|
|
# 1. Rename to pre-commit
|
|
# 2. Copy to .git/hooks/pre-commit
|
|
|
|
docker ps 1> /dev/null 2>&1
|
|
|
|
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 \
|
|
bbcnews/rubocop-config --format simple --fail-level F 2> /dev/null | grep '^F:' | wc -l | tr -d '[[:space:]]')
|
|
|
|
if [ $errors -gt 0 ]; then
|
|
echo "Rubocop reported $errors errors. Please double check your code"
|
|
exit 1
|
|
fi
|