tnuctipun 0.2.0

The Tnuctipun of Ringworld — ancient, subversive, ingenious — or a type-safe MongoDB builder library
Documentation
#!/bin/bash

# Git pre-push hook to check cargo fmt and clippy
# This hook will prevent pushing code that is not properly formatted or has clippy warnings

echo "Running code quality checks before push..."

# Check if cargo fmt would make any changes
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!"

# Check clippy warnings
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!"

# Source git utility functions
# Get the repository root directory
REPO_ROOT="$(git rev-parse --show-toplevel)"

source "$REPO_ROOT/scripts/git-utils.sh"

# Check documentation snippets only if there are changes to .md files in the pushed commits
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