-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Git pre-push hook with install script that checks fmt and clippy
- Loading branch information
Showing
3 changed files
with
41 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
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,19 @@ | ||
#!/bin/sh | ||
|
||
echo "Running pre-push hook..." | ||
|
||
# Run cargo fmt to format the code | ||
if ! cargo fmt -- --check; then | ||
echo "Code is not formatted. Please run 'cargo fmt' to format the code." | ||
exit 1 | ||
fi | ||
|
||
# Run cargo clippy to check for linting issues | ||
if ! cargo clippy -- -D warnings; then | ||
echo "Clippy found warnings. Please fix them before pushing." | ||
exit 1 | ||
fi | ||
|
||
# If both checks pass, allow the push to proceed | ||
exit 0 | ||
|
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,13 @@ | ||
#!/bin/sh | ||
|
||
# Create the hooks directory if it doesn't exist | ||
mkdir -p .git/hooks | ||
|
||
# Copy the pre-push hook to the Git hooks directory | ||
cp hooks/pre-push .git/hooks/pre-push | ||
chmod +x .git/hooks/pre-push | ||
|
||
# Configure Git to use the custom hooks directory | ||
git config core.hooksPath .git/hooks | ||
|
||
echo "Git Hooks installed and configured." |