chore: add git hooks (#35)
Reviewed-on: #35 Co-authored-by: Felipe Contreras Salinas <felipe@bstr.cl> Co-committed-by: Felipe Contreras Salinas <felipe@bstr.cl>
This commit is contained in:
parent
c992711ab3
commit
9d5680e133
5 changed files with 45 additions and 1 deletions
|
|
@ -1,5 +1,11 @@
|
|||
# Changelog
|
||||
|
||||
## [unreleased]
|
||||
|
||||
### Miscellaneous Tasks
|
||||
|
||||
- Add git hooks
|
||||
|
||||
## [0.2.2] - 2023-11-10
|
||||
|
||||
### Bug Fixes
|
||||
|
|
|
|||
2
build.rs
2
build.rs
|
|
@ -2,4 +2,4 @@
|
|||
fn main() {
|
||||
// trigger recompilation when a new migration is added
|
||||
println!("cargo:rerun-if-changed=migrations");
|
||||
}
|
||||
}
|
||||
|
|
|
|||
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