Skip to content

Commit 22d7f92

Browse files
authored
pre-commit hooks (#973)
2 parents 330edaa + bb3286f commit 22d7f92

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed

.git_hooks/pre-commit

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#!/usr/bin/env sh
2+
if ! cargo fmt -- --check ; then
3+
printf "\n"
4+
printf "\033[0;31mpre-commit hook failed during:\033[0m\n"
5+
printf "\033[0;31m\tcargo fmt -- --check\033[0m\n"
6+
exit 1
7+
fi
8+
9+
if ! cargo clippy --locked -- -D warnings ; then
10+
printf "\n"
11+
printf "\033[0;31mpre-commit hook failed during:\033[0m\n"
12+
printf "\033[0;31m\tclippy --locked -- -D warning\033[0m\n"
13+
exit 1
14+
fi
15+
16+
printf "\n"
17+
printf "\033[0;32mpre-commit hook succeeded\033[0m\n"

README.md

+11
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,17 @@ The recommended way to develop docs.rs is a combination of `cargo run` for
2222
the main binary and [docker-compose](https://docs.docker.com/compose/) for the external services.
2323
This gives you reasonable incremental build times without having to add new users and packages to your host machine.
2424

25+
### Git Hooks
26+
27+
For ease of use, `git_hooks` directory contains useful `git hooks` to make your development easier.
28+
29+
```bash
30+
# Unix
31+
cd .git/hooks && ln -s ../../.git_hooks/* . && cd ../..
32+
# Powershell
33+
cd .git/hooks && New-Item -Path ../../.git_hooks/* -ItemType SymbolicLink -Value . && cd ../..
34+
```
35+
2536
### Dependencies
2637

2738
Docs.rs requires at least the following native C dependencies.

0 commit comments

Comments
 (0)