anya-core 1.2.0

Enterprise-grade Bitcoin Infrastructure Platform
Documentation
# Git Hooks for Anya Core
# These hooks enforce local development standards

## Pre-commit Hook
This hook runs before each commit to ensure code quality:

```bash
#!/bin/bash
# Save as .git/hooks/pre-commit and make executable

echo "๐Ÿ” Running pre-commit checks..."

# Check branch protection
if [[ "$(git branch --show-current)" == "main" ]]; then
    echo "โŒ Direct commits to main branch are not allowed!"
    echo "Please create a feature branch and submit a PR."
    exit 1
fi

# Run cargo fmt check
echo "๐Ÿ“ Checking code formatting..."
if ! cargo fmt -- --check; then
    echo "โŒ Code formatting issues found!"
    echo "Run 'cargo fmt' to fix them."
    exit 1
fi

# Run clippy
echo "๐Ÿ” Running clippy..."
if ! cargo clippy --all-targets --all-features -- -D warnings; then
    echo "โŒ Clippy found issues!"
    exit 1
fi

# Check for secrets
echo "๐Ÿ” Scanning for secrets..."
if grep -r -E "(api_key|secret|password|token|private_key)" --include="*.rs" src/ | grep -v "test" | grep -v "example"; then
    echo "โŒ Potential secrets found! Please remove them."
    exit 1
fi

echo "โœ… Pre-commit checks passed!"
```

## Commit-msg Hook
This hook validates commit message format:

```bash
#!/bin/bash
# Save as .git/hooks/commit-msg and make executable

commit_regex='^(feat|fix|docs|style|refactor|test|chore|perf|ci|build|revert)(\(.+\))?: .+'
emoji_regex='^(๐Ÿ”ง|๐Ÿ“Š|โœจ|๐Ÿ›|๐Ÿ“|๐Ÿ’„|โ™ป๏ธ|๐Ÿงช|๐Ÿ”จ|โšก|๐Ÿ‘ท|๐Ÿ—๏ธ|โช)'

if ! grep -qE "$commit_regex" "$1" && ! grep -qE "$emoji_regex" "$1"; then
    echo "โŒ Invalid commit message format!"
    echo "Use: type(scope): description"
    echo "Types: feat, fix, docs, style, refactor, test, chore, perf, ci, build, revert"
    echo "Or emojis: ๐Ÿ”ง โœจ ๐Ÿ› ๐Ÿ“ ๐Ÿ’„ โ™ป๏ธ ๐Ÿงช ๐Ÿ”จ โšก ๐Ÿ‘ท ๐Ÿ—๏ธ โช"
    exit 1
fi
```

## Pre-push Hook
This hook runs before pushing to remote:

```bash
#!/bin/bash
# Save as .git/hooks/pre-push and make executable

echo "๐Ÿš€ Running pre-push checks..."

# Ensure all commits are signed
commits=$(git rev-list @{u}..HEAD 2>/dev/null || git rev-list HEAD)
for commit in $commits; do
    if ! git verify-commit $commit 2>/dev/null; then
        echo "โŒ Commit $commit is not signed!"
        echo "Please sign commits with 'git commit -S'"
        exit 1
    fi
done

# Run tests
echo "๐Ÿงช Running tests..."
if ! cargo test; then
    echo "โŒ Tests failed!"
    exit 1
fi

echo "โœ… Pre-push checks passed!"
```

## Installation
Run this script to install all hooks:

```bash
#!/bin/bash
# Install git hooks
cp hooks/pre-commit .git/hooks/
cp hooks/commit-msg .git/hooks/
cp hooks/pre-push .git/hooks/
chmod +x .git/hooks/*
echo "โœ… Git hooks installed!"
```