- Создаем в корне апп папку
scripts
- Сооздаем в ней несколько файлов со следующим содержимым
#!/usr/bin/env bash
set -e
cd "${0%/*}/.."
echo "Running tests"
bundle exec rspec
#!/usr/bin/env bash
set -e
cd "${0%/*}/.."
echo "Running rubocop"
bundle exec rubocop -A
#!/usr/bin/env bash
set -e
cd "${0%/*}/.."
echo "Running brakeman"
bundle exec brakeman -6
#!/usr/bin/env bash
echo "Running pre-push hook"
./scripts/run-brakeman.bash
./scripts/run-tests.bash
# $? stores exit value of the last command
if [ $? -ne 0 ]; then
echo "Brakeman and Tests must pass before pushing!"
exit 1
fi
#!/usr/bin/env bash
echo "Running pre-commit hook"
./scripts/run-rubocop.bash
# $? stores exit value of the last command
if [ $? -ne 0 ]; then
echo "Code must be clean before commiting"
exit 1
fi
#!/usr/bin/env bash
GIT_DIR=$(git rev-parse --git-dir)
echo "Installing hooks..."
# this command creates symlink to our pre-commit script
ln -s ../../scripts/pre-commit.bash $GIT_DIR/hooks/pre-commit
ln -s ../../scripts/pre-push.bash $GIT_DIR/hooks/pre-push
echo "Done!"
- Выполняем команду
$ chmod +x scripts/*.bash
$ ./scripts/install-hooks.bash
Installing hooks...
Done!
Всё. Вы прекрасны
Спасибо!)))