2025-11-30 21:58:08 -05:00
|
|
|
#!/bin/sh
|
|
|
|
|
#
|
|
|
|
|
# Pre-commit hook for localspot
|
2025-12-01 00:15:09 -05:00
|
|
|
# Runs formatting and tests before allowing commits
|
2025-11-30 21:58:08 -05:00
|
|
|
#
|
|
|
|
|
# To install: cp scripts/pre-commit .git/hooks/pre-commit
|
|
|
|
|
|
|
|
|
|
set -e
|
|
|
|
|
|
|
|
|
|
echo "Running pre-commit checks..."
|
|
|
|
|
|
2025-12-01 00:15:09 -05:00
|
|
|
# Format code and stage any changes
|
|
|
|
|
echo "Formatting code..."
|
|
|
|
|
mix format
|
|
|
|
|
git add -u
|
2025-11-30 21:58:08 -05:00
|
|
|
|
|
|
|
|
# Run tests
|
|
|
|
|
echo "Running tests..."
|
|
|
|
|
mix test
|
|
|
|
|
if [ $? -ne 0 ]; then
|
|
|
|
|
echo "❌ Tests failed. Please fix before committing."
|
|
|
|
|
exit 1
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
echo "✅ All pre-commit checks passed!"
|