Skip to content

Commit eccc224

Browse files
author
Davide Melfi
committed
chore: add pre commit script for anyone that wants to use it.
1 parent 00e90ad commit eccc224

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

scripts/pre-commit

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#!/bin/sh
2+
# Pre-commit hook to run cargo fmt
3+
#
4+
# To install this hook, run:
5+
# cp scripts/pre-commit .git/hooks/pre-commit
6+
# chmod +x .git/hooks/pre-commit
7+
8+
echo "Running cargo fmt..."
9+
10+
# Run cargo fmt on the entire workspace
11+
cargo fmt --all -- --check
12+
13+
# Check if cargo fmt found any formatting issues
14+
if [ $? -ne 0 ]; then
15+
echo ""
16+
echo "❌ Code formatting issues detected!"
17+
echo "Running 'cargo fmt --all' to fix formatting..."
18+
cargo fmt --all
19+
echo ""
20+
echo "✅ Formatting applied. Please review the changes and commit again."
21+
exit 1
22+
fi
23+
24+
echo "✅ Code formatting is correct!"
25+
exit 0

0 commit comments

Comments
 (0)