29 lines
591 B
Text
29 lines
591 B
Text
|
|
#!/bin/sh
|
||
|
|
#
|
||
|
|
# Pre-commit hook for localspot
|
||
|
|
# Runs formatting check and tests before allowing commits
|
||
|
|
#
|
||
|
|
# To install: cp scripts/pre-commit .git/hooks/pre-commit
|
||
|
|
|
||
|
|
set -e
|
||
|
|
|
||
|
|
echo "Running pre-commit checks..."
|
||
|
|
|
||
|
|
# Check formatting (without modifying files)
|
||
|
|
echo "Checking code formatting..."
|
||
|
|
mix format --check-formatted
|
||
|
|
if [ $? -ne 0 ]; then
|
||
|
|
echo "❌ Code is not formatted. Run 'mix format' to fix."
|
||
|
|
exit 1
|
||
|
|
fi
|
||
|
|
|
||
|
|
# 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!"
|