This repository has been archived on 2026-01-06. You can view files and clone it, but you cannot make any changes to it's state, such as pushing and creating new issues, pull requests or comments.
fej/.hooks/pre-commit
Jef Roosens 6af5368a87
Error handler now returns a string instead (closes #10)
Commit hook now properly returns status code on failed formatting
2021-04-04 15:13:36 +02:00

17 lines
505 B
Bash
Executable file

#!/usr/bin/env bash
# This hook lints the code, and if we're on develop or master, also forces the tests to pass.
make lint &> /dev/null 2>&1 || {
>&2 echo "Format check failed, use 'make lint' for more information.";
exit 1;
}
branch=`git rev-parse --abbrev-ref HEAD`
# TODO should we add release branches here as well?
if [[ "$branch" =~ ^master|develop$ ]]; then
make test > /dev/null 2>&1 || {
>&2 echo "Tests failed. check 'make test' for more info.";
exit 1;
}
fi