# See https://pre-commit.com for more information
# See https://pre-commit.com/hooks.html for more hooks
repos:
  - repo: local
    hooks:
      # Format code with rustfmt
      - id: cargo-fmt
        name: cargo fmt
        entry: cargo fmt --check
        language: system
        types: [rust]
        pass_filenames: false
        always_run: true

      # Lint with clippy
      - id: cargo-clippy
        name: cargo clippy
        entry: cargo clippy -- -D warnings
        language: system
        types: [rust]
        pass_filenames: false
        always_run: true

      # Run tests
      - id: cargo-test
        name: cargo test
        entry: cargo test
        language: system
        types: [rust]
        pass_filenames: false
        always_run: true

      
      # Security audit (install cargo-audit if not present)
      - id: cargo-audit
        name: cargo audit
        entry: bash -c 'if ! command -v cargo-audit &> /dev/null; then echo "📦 Installing cargo-audit..."; cargo install cargo-audit; fi && cargo audit'
        language: system
        types: [rust]
        pass_filenames: false
        always_run: true

      # Check documentation
      - id: cargo-doc
        name: cargo doc
        entry: cargo doc --no-deps
        language: system
        types: [rust]
        pass_filenames: false
        always_run: true

      # Build in release mode (matching CI)
      - id: cargo-build-release
        name: cargo build --release
        entry: bash -c 'echo "🔨 Building in release mode..." && cargo build --release && echo "🧹 Cleaning build artifacts..." && rm -rf target/release'
        language: system
        types: [rust]
        pass_filenames: false
        always_run: true