sphinx-ultra 0.3.0

High-performance Rust-based Sphinx documentation builder for large codebases
Documentation
#!/bin/bash
# Git pre-push hook to validate version consistency
#
# This hook prevents pushing tags that don't match the Cargo.toml version.
# To install: cp scripts/pre-push .git/hooks/pre-push && chmod +x .git/hooks/pre-push

set -euo pipefail

# Colors
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
NC='\033[0m'

# Read from stdin (git provides: local_ref local_sha remote_ref remote_sha)
while read local_ref local_sha remote_ref remote_sha; do
    # Check if this is a tag push
    if [[ $local_ref == refs/tags/* ]]; then
        tag_name=${local_ref#refs/tags/}
        
        # Only check version tags (starting with 'v')
        if [[ $tag_name =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
            tag_version=${tag_name#v}
            
            echo -e "${YELLOW}Validating version tag: $tag_name${NC}"
            
            # Get Cargo.toml version
            if [ ! -f "Cargo.toml" ]; then
                echo -e "${RED}Error: Cargo.toml not found${NC}"
                exit 1
            fi
            
            cargo_version=$(grep '^version = ' Cargo.toml | head -n1 | sed 's/version = "\(.*\)"/\1/')
            
            echo "  Tag version: $tag_version"
            echo "  Cargo.toml version: $cargo_version"
            
            if [ "$tag_version" != "$cargo_version" ]; then
                echo -e "${RED}❌ ERROR: Version mismatch detected!${NC}"
                echo -e "Cannot push tag $tag_name because it doesn't match Cargo.toml version ($cargo_version)"
                echo ""
                echo -e "${YELLOW}To fix this:${NC}"
                echo "1. Update Cargo.toml version to $tag_version, OR"
                echo "2. Delete this tag and create one matching Cargo.toml version ($cargo_version)"
                echo "3. Use scripts/release.sh to automate releases safely"
                echo ""
                echo "Commands to fix:"
                echo "  git tag -d $tag_name  # Delete the tag"
                echo "  ./scripts/release.sh $cargo_version  # Create proper release"
                exit 1
            fi
            
            echo -e "${GREEN}✅ Version validation passed${NC}"
        fi
    fi
done

exit 0