Compare commits

...

1 commit

Author SHA1 Message Date
5ce67a449d
chore: add git hooks 2023-11-18 21:27:19 -03:00
4 changed files with 39 additions and 1 deletions

11
hooks/install.sh Executable file
View file

@ -0,0 +1,11 @@
#!/bin/bash
set -eu
if GIT_ROOT="$(git rev-parse --show-toplevel)"; then
ln -s $GIT_ROOT/hooks/pre-commit.sh $GIT_ROOT/.git/hooks/pre-commit
ln -s $GIT_ROOT/hooks/pre-push.sh $GIT_ROOT/.git/hooks/pre-push
else
echo "Failed to get git root, aborting"
exit 1
fi

11
hooks/pre-commit.sh Executable file
View file

@ -0,0 +1,11 @@
#!/bin/bash
set -eu
if ! cargo fmt -- --check
then
echo "There are some code style issues."
echo "Run cargo fmt first."
exit 1
fi
exit 0

16
hooks/pre-push.sh Executable file
View file

@ -0,0 +1,16 @@
#!/bin/bash
set -eu
if ! cargo clippy --all-targets -- -D warnings
then
echo "There are some clippy issues."
exit 1
fi
if ! cargo test
then
echo "There are some test issues."
exit 1
fi
exit 0