# Generated by alef scaffold. Customize as needed.
default_install_hook_types:
  - pre-commit
  - commit-msg
exclude: ^target/|\.alef/

repos:
  # Commit message linting
  - repo: https://github.com/Goldziher/gitfluff
    rev: {{ gitfluff }}
    hooks:
      - id: gitfluff-lint
        args: ["--write"]
        stages: [commit-msg]

  # General file checks
  - repo: https://github.com/pre-commit/pre-commit-hooks
    rev: {{ pre_commit_hooks }}
    hooks:
      - id: trailing-whitespace
      - id: end-of-file-fixer
      - id: check-merge-conflict
      - id: check-added-large-files
      - id: detect-private-key
      - id: check-json
      - id: check-yaml
        args: ["--allow-multiple-documents", "--unsafe"]
      - id: check-toml
      - id: check-case-conflict

{% if has_python %}
  - repo: https://github.com/tox-dev/pyproject-fmt
    rev: "{{ pyproject_fmt }}"
    hooks:
      - id: pyproject-fmt

{% endif %}
  - repo: https://github.com/DevinR528/cargo-sort
    rev: "{{ cargo_sort }}"
    hooks:
      - id: cargo-sort
        args: [-w]

  # Rust: formatting, linting, unused deps, license/advisory
  - repo: https://github.com/AndrejOrsula/pre-commit-cargo
    rev: {{ pre_commit_cargo }}
    hooks:
      - id: cargo-fmt
        args: ["--all"]
        types: [rust]
      - id: cargo-clippy
        args:
          [
            "--fix",
            "--allow-dirty",
            "--allow-staged",
            "--workspace",
            "--all-features",
{{ clippy_excludes }}            "--all-targets",
            "--",
            "-D",
            "warnings",
          ]

  - repo: https://github.com/bnjbvr/cargo-machete
    rev: {{ cargo_machete }}
    hooks:
      - id: cargo-machete

  - repo: https://github.com/EmbarkStudios/cargo-deny
    rev: {{ cargo_deny }}
    hooks:
      - id: cargo-deny
        args: ["check"]

  # Markdown
  - repo: https://github.com/rvben/rumdl-pre-commit
    rev: "{{ rumdl }}"
    hooks:
      - id: rumdl-fmt

{% if include_shared_hooks %}
  # Shell, Dockerfile, and docs prose (shared hooks)
  - repo: {{ shared_hooks_repo }}
    rev: {{ shared_hooks_rev }}
    hooks:
      - id: shfmt
      - id: shellcheck
      - id: hadolint
      - id: textlint

{% endif %}
{% if include_alef_hooks %}
  # Alef: generate READMEs, verify bindings, sync versions
{% if alef_hooks_are_local %}
  - repo: local
    hooks:
      - id: alef-readme
        name: alef readme
        entry: alef readme
        language: system
        pass_filenames: false
      - id: alef-verify
        name: alef verify
        entry: alef verify --exit-code
        language: system
        pass_filenames: false
      - id: alef-sync-versions
        name: alef sync versions
        entry: alef sync-versions
        language: system
        pass_filenames: false
{% else %}
  - repo: {{ alef_hooks_repo }}
    rev: {{ alef_hooks_rev }}
    hooks:
      - id: alef-readme
      - id: alef-verify
      - id: alef-sync-versions
{% endif %}

{% endif %}
  # Spelling
  - repo: https://github.com/crate-ci/typos
    rev: {{ typos }}
    hooks:
      - id: typos
        args: ["--force-exclude"]
