-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Christopher Hock
authored
Jan 13, 2024
1 parent
f06a3b8
commit 0616f08
Showing
3 changed files
with
27 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
repos: | ||
- repo: local | ||
hooks: | ||
- id: rustfmt | ||
name: autoformat | ||
entry: .pre-commit-hooks/rustfmt.sh | ||
language: script | ||
files: \.rs$ | ||
|
||
- id: clippy | ||
name: clippy_linter | ||
entry: .pre-commit-hooks/clippy.sh | ||
language: script | ||
files: \.rs$ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#!/bin/sh | ||
cargo clippy -- -Dwarnings 2> /dev/null | ||
clippy_exit_code=$? | ||
if [ $clippy_exit_code != 0 ]; then | ||
echo -e "\e[31mYour code seems to contains style violations! Run cargo clippy before committing!\e[0m" ; exit 1 | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
#!/bin/sh | ||
STAGED=$(git diff --name-only --cached | grep '.*\.rs') | ||
if ! [ "$STAGED" = '' ]; then | ||
rustfmt --check "$STAGED" || { | ||
echo -e "\e[31mYour code is not formatted correctly! Please run rustfmt on all staged files before committing!\e[0m" ; exit 1 | ||
} | ||
fi |