# To use:
#
#     pre-commit run -a
#
# Or:
#
#     pre-commit install  # (runs every time you commit in git)
#
# To update this file:
#
#     pre-commit autoupdate
#
# See https://github.com/pre-commit/pre-commit

fail_fast: false
exclude: |
  (?x)(
    ^(.vscode/.*)
  )
files: '' # set '' as default

repos:
  # Standard hooks
  - repo: https://github.com/pre-commit/pre-commit-hooks
    rev: v5.0.0
    hooks:
      - id: check-added-large-files
        args: [--maxkb=4096]
      - id: check-case-conflict
      - id: check-merge-conflict
      - id: check-symlinks
      - id: debug-statements
      - id: end-of-file-fixer
      - id: mixed-line-ending
      - id: name-tests-test
        args: [--pytest-test-first]
      - id: requirements-txt-fixer
      - id: trailing-whitespace

  # Check RST
  - repo: https://github.com/pre-commit/pygrep-hooks
    rev: v1.10.0
    hooks:
      - id: rst-backticks
      - id: rst-directive-colons
      - id: rst-inline-touching-normal

  # Strong lint from ruff
  - repo: https://github.com/astral-sh/ruff-pre-commit
    rev: v0.11.4
    hooks:
      - id: ruff
        args: [--fix, --show-fixes]
      - id: ruff-format

  # Mypy Check
  - repo: https://github.com/pre-commit/mirrors-mypy
    rev: v1.15.0
    hooks:
      - id: mypy
        files: src|tests
        args: []
        additional_dependencies:
          - pytest
          - importlib_metadata

  # Check yaml
  - repo: https://github.com/macisamuele/language-formatters-pre-commit-hooks
    rev: v2.14.0
    hooks:
      - id: pretty-format-yaml
        args:
          - --autofix
          - --offset=2
        exclude: |
          (?x)(
            .copier-answers.yml
          )

  # Changes tabs to spaces
  - repo: https://github.com/Lucas-C/pre-commit-hooks
    rev: v1.5.5
    hooks:
      - id: remove-tabs

  # CMake formatting
  - repo: https://github.com/cheshirekow/cmake-format-precommit
    rev: v0.6.13
    hooks:
      - id: cmake-format
        additional_dependencies: [pyyaml]
        types: [file]
        files: (\.cmake|CMakeLists.txt)(.in)?$
        exclude: |
          (?x)(
              ^(cmake/vcpkg/ports/.*) |
              ^(cmake/vcpkg/triplets/.*) |
              ^(cmake/vcpkg/scripts/toolchains/.*)
[%- if repo_name ==  'ss-pybind11' %] |
              ^(template/cmake/vcpkg/ports/.*) |
              ^(template/cmake/vcpkg/triplets/.*) |
              ^(template/cmake/vcpkg/scripts/toolchains/.*)
[%- endif %]
          )

  # Check pyproject
  - repo: https://github.com/abravalheri/validate-pyproject
    rev: v0.24.1
    hooks:
      - id: validate-pyproject
        additional_dependencies: ['validate-pyproject-schema-store[all]>=2024.10.21']

  # Check jsonschema
  - repo: https://github.com/python-jsonschema/check-jsonschema
    rev: 0.32.1
    hooks:
      - id: check-dependabot
      - id: check-github-workflows
      - id: check-readthedocs

  # Check for spelling
  - repo: https://github.com/codespell-project/codespell
    rev: v2.4.1
    hooks:
      - id: codespell
        args:
          - -L=lang
          - --check-filenames
          - --write-changes

  # Check for common shell mistakes
  - repo: https://github.com/shellcheck-py/shellcheck-py
    rev: v0.9.0.6
    hooks:
      - id: shellcheck
[%- if compiled ==  true %]

  # Clang format the codebase automatically
  - repo: https://github.com/pre-commit/mirrors-clang-format
    rev: v20.1.0
    hooks:
      - id: clang-format
        types_or: [c++, c, cuda]
[%- endif %]

  # Check for markdown
  - repo: https://github.com/igorshubovych/markdownlint-cli
    rev: v0.44.0
    hooks:
      - id: markdownlint-fix

  # Check for renovate config
  - repo: https://github.com/renovatebot/pre-commit-hooks
    rev: 39.227.2
    hooks:
      - id: renovate-config-validator
        stages: [manual]

  - repo: local
    hooks:
      - id: disallow-caps
        name: Disallow improper capitalization
        language: pygrep
        entry: PyBind|Numpy|Cmake|CCache|Github|PyTest
        exclude: .pre-commit-config.yaml
