-
Notifications
You must be signed in to change notification settings - Fork 52
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Automatically `cargo clippy` and others before you commit
- Loading branch information
1 parent
4e69a9a
commit f59b893
Showing
3 changed files
with
36 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,24 @@ | ||
#/bin/sh | ||
|
||
function check { | ||
prog=$1 | ||
shift | ||
"$prog" "$@" | ||
if [ $? -ne 0 ]; then | ||
exit 1 | ||
fi | ||
} | ||
|
||
check cargo clippy | ||
|
||
staged_py_files=$(git diff --cached --name-only --diff-filter=ACM | grep '\.py$') | ||
|
||
if [ -n "$staged_py_files" ]; then | ||
flake8_executable=$(which flake8 || which flake) | ||
if [ -z "$flake8_executable" ]; then | ||
echo "flake is not installed" | ||
exit 1 | ||
else | ||
check "$flake8_executable" $staged_py_files | ||
fi | ||
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
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 | ||
|
||
for hook in .hooks/*; do | ||
hook_name=$(basename "$hook") | ||
cp "$hook" ".git/hooks/$hook_name" && chmod +x ".git/hooks/$hook_name" | ||
done | ||
echo "Done" |