echo "Running code quality checks before push..."
echo "🔍 Checking code formatting..."
if ! cargo fmt --check --quiet; then
echo "❌ Code formatting check failed!"
echo ""
echo "Please run 'cargo fmt' to format your code before pushing."
echo "You can also run 'cargo fmt --check' to see what needs formatting."
echo ""
echo "Push aborted."
exit 1
fi
echo "✅ Code formatting check passed!"
echo "🔍 Checking clippy warnings..."
if ! cargo clippy --all-targets --all-features -- -D warnings; then
echo "❌ Clippy check failed!"
echo ""
echo "Please fix all clippy warnings before pushing."
echo "You can run 'cargo clippy --all-targets --all-features -- -D warnings' to see the issues."
echo ""
echo "Push aborted."
exit 1
fi
echo "✅ Clippy check passed!"
REPO_ROOT="$(git rev-parse --show-toplevel)"
source "$REPO_ROOT/scripts/git-utils.sh"
echo "🔍 Checking for Markdown file changes in pushed commits..."
if check_files_changed "md"; then
echo "📝 Markdown files changed in pushed commits"
echo "📝 Markdown changes detected in push, checking documentation snippets..."
if ! ./tools/doc-checker/doc-checker > /dev/null 2>&1; then
echo "❌ Documentation snippets check failed!"
echo ""
echo "Please fix the failing documentation examples before pushing."
echo "You can run './tools/doc-checker/doc-checker' to see the issues."
echo ""
echo "Push aborted."
exit 1
fi
echo "✅ Documentation snippets check passed!"
else
echo "📝 No Markdown file changes in pushed commits, skipping documentation snippets check."
fi
echo "🎉 All code quality checks passed! Ready to push."
exit 0