# Pre-commit hooks for embellama
# See https://pre-commit.com for more information

repos:
  # General file checks
  - repo: https://github.com/pre-commit/pre-commit-hooks
    rev: v4.5.0
    hooks:
      - id: trailing-whitespace
      - id: end-of-file-fixer
      - id: check-yaml
      - id: check-toml
      - id: check-added-large-files

  # Rust-specific hooks using just commands
  - repo: local
    hooks:
      - id: rustfmt
        name: rustfmt
        entry: just fmt
        language: system
        pass_filenames: false
        files: \.rs$

      - id: clippy
        name: clippy
        entry: just clippy
        language: system
        pass_filenames: false
        files: \.rs$

      - id: check
        name: cargo check
        entry: just check
        language: system
        pass_filenames: false
        files: \.rs$

      - id: test-compile
        name: test compilation
        entry: just test-compile
        language: system
        pass_filenames: false
        files: \.rs$

      - id: test-doc
        name: doc tests
        entry: just test-doc
        language: system
        pass_filenames: false
        files: (\.rs$|README\.md$)

  # Security audit (optional - only if cargo-audit is installed)
  - repo: local
    hooks:
      - id: cargo-audit
        name: cargo audit
        entry: bash -c 'command -v cargo-audit >/dev/null 2>&1 && cargo audit || echo "Skipping audit (cargo-audit not installed)"'
        language: system
        pass_filenames: false
        files: Cargo\.(toml|lock)$
        stages: [manual]  # Only run manually with --hook-stage manual

  # Documentation checks (manual stage only)
  - repo: local
    hooks:
      - id: doc-check
        name: documentation check
        entry: just doc
        language: system
        pass_filenames: false
        files: \.rs$
        stages: [manual]  # Only run when explicitly requested

# Configuration
default_stages: [pre-commit]
fail_fast: false
