edge-connect-mcp/scripts/hooks/pre-commit

28 lines
619 B
Bash
Executable file

#!/bin/bash
# ABOUTME: Pre-commit hook that runs formatting and linting checks.
# ABOUTME: Install with `make install-hooks`.
set -e
echo "Running pre-commit checks..."
# Run go fmt and check if there are any changes
echo "Checking formatting..."
UNFORMATTED=$(gofmt -l .)
if [ -n "$UNFORMATTED" ]; then
echo "Error: The following files are not formatted:"
echo "$UNFORMATTED"
echo ""
echo "Run 'make fmt' to format them."
exit 1
fi
# Run linter
echo "Running linter..."
make lint
# Check for secrets with gitleaks
echo "Checking for secrets..."
make gitleaks
echo "Pre-commit checks passed!"