chore: add git hooks
This commit is contained in:
parent
c992711ab3
commit
59668b1b38
4 changed files with 39 additions and 1 deletions
11
hooks/install.sh
Executable file
11
hooks/install.sh
Executable 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
11
hooks/pre-commit.sh
Executable 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
16
hooks/pre-push.sh
Executable 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
|
||||||
Loading…
Add table
Reference in a new issue