repos:
  # Rust formatting and linting
  - repo: local
    hooks:
      # Format Rust code
      - id: cargo-fmt
        name: cargo fmt
        entry: cargo fmt --all -- --check
        language: system
        files: \.rs$
        pass_filenames: false

      # Lint Rust code with Clippy
      - id: cargo-clippy
        name: cargo clippy
        entry: cargo clippy --all-targets --all-features -- -D warnings
        language: system
        files: \.rs$
        pass_filenames: false

      # Check Rust compilation
      - id: cargo-check
        name: cargo check
        entry: cargo check --all-targets --all-features
        language: system
        files: \.rs$
        pass_filenames: false

      # Run Rust tests
      - id: cargo-test
        name: cargo test
        entry: cargo test --verbose
        language: system
        files: \.rs$
        pass_filenames: false

  - repo: local
    hooks:
      - id: cargo-audit
        name: cargo audit
        entry: cargo audit
        language: system
        files: Cargo\.(toml|lock)$
        pass_filenames: false
        stages: [manual]

  # General file checks
  - repo: https://github.com/pre-commit/pre-commit-hooks
    rev: v5.0.0
    hooks:
      - id: trailing-whitespace
      - id: end-of-file-fixer
      - id: check-yaml
      - id: check-toml
      - id: check-merge-conflict
      - id: check-added-large-files
        args: ["--maxkb=1024"]
