diff --git a/.git_hooks/pre-commit b/.git_hooks/pre-commit new file mode 100755 index 000000000..0c7b0eb40 --- /dev/null +++ b/.git_hooks/pre-commit @@ -0,0 +1,17 @@ +#!/usr/bin/env sh +if ! cargo fmt -- --check ; then + printf "\n" + printf "\033[0;31mpre-commit hook failed during:\033[0m\n" + printf "\033[0;31m\tcargo fmt -- --check\033[0m\n" + exit 1 +fi + +if ! cargo clippy --locked -- -D warnings ; then + printf "\n" + printf "\033[0;31mpre-commit hook failed during:\033[0m\n" + printf "\033[0;31m\tclippy --locked -- -D warning\033[0m\n" + exit 1 +fi + +printf "\n" +printf "\033[0;32mpre-commit hook succeeded\033[0m\n" diff --git a/README.md b/README.md index 8f6155ec7..796d363ee 100644 --- a/README.md +++ b/README.md @@ -22,6 +22,17 @@ The recommended way to develop docs.rs is a combination of `cargo run` for the main binary and [docker-compose](https://docs.docker.com/compose/) for the external services. This gives you reasonable incremental build times without having to add new users and packages to your host machine. +### Git Hooks + +For ease of use, `git_hooks` directory contains useful `git hooks` to make your development easier. + +```bash +# Unix +cd .git/hooks && ln -s ../../.git_hooks/* . && cd ../.. +# Powershell +cd .git/hooks && New-Item -Path ../../.git_hooks/* -ItemType SymbolicLink -Value . && cd ../.. +``` + ### Dependencies Docs.rs requires at least the following native C dependencies.