---
# pre-commit is a tool to perform a predefined set of tasks manually and/or
# automatically before git commits are made.
#
# Config reference: https://pre-commit.com/#pre-commit-configyaml---top-level
#
# Common tasks
#
# - Run on all files:   pre-commit run --all-files
# - Register git hooks: pre-commit install --hook-type pre-commit --hook-type pre-push
#
# See https://pre-commit.com for more information
# See https://pre-commit.com/hooks.html for more hooks
exclude: ^(docs/doxygen-awesome-theme/|conan\.lock$)

repos:
  # `pre-commit sample-config` default hooks
  - repo: https://github.com/pre-commit/pre-commit-hooks
    rev: cef0300fd0fc4d2a87a85fa2093c6b283ea36f4b # frozen: v5.0.0
    hooks:
      - id: check-added-large-files
      - id: check-executables-have-shebangs
      - id: check-shebang-scripts-are-executable
      - id: end-of-file-fixer
      - id: trailing-whitespace

  # Autoformat: YAML, JSON, Markdown, etc.
  - repo: https://github.com/rbubley/mirrors-prettier
    rev: 787fb9f542b140ba0b2aced38e6a3e68021647a3 # frozen: v3.5.3
    hooks:
      - id: prettier

  - repo: https://github.com/igorshubovych/markdownlint-cli
    rev: 586c3ea3f51230da42bab657c6a32e9e66c364f0 # frozen: v0.44.0
    hooks:
      - id: markdownlint-fix
        exclude: LICENSE.md

  - repo: https://github.com/hadolint/hadolint
    rev: c3dc18df7a501f02a560a2cc7ba3c69a85ca01d3 # frozen: v2.13.1-beta
    hooks:
      - id: hadolint-docker
        # hadolint-docker is a special hook that runs hadolint in a Docker container
        # Docker is not installed in the environment where pre-commit is run
        stages: [manual]
        entry: hadolint/hadolint:v2.12.1-beta hadolint

  - repo: https://github.com/codespell-project/codespell
    rev: 63c8f8312b7559622c0d82815639671ae42132ac # frozen: v2.4.1
    hooks:
      - id: codespell
        args:
          [
            --write-changes,
            --ignore-words=pre-commit-hooks/codespell_ignore.txt,
          ]

  # Running fix-local-includes before clang-format
  # to ensure that the include order is correct.
  - repo: local
    hooks:
      - id: fix-local-includes
        name: Fix Local Includes
        entry: pre-commit-hooks/fix-local-includes.sh
        types: [c++]
        language: script
  - repo: https://github.com/pre-commit/mirrors-clang-format
    rev: f9a52e87b6cdcb01b0a62b8611d9ba9f2dad0067 # frozen: v19.1.7
    hooks:
      - id: clang-format
        args: [--style=file]
        types: [c++]

  - repo: https://github.com/cheshirekow/cmake-format-precommit
    rev: e2c2116d86a80e72e7146a06e68b7c228afc6319 # frozen: v0.6.13
    hooks:
      - id: cmake-format
        additional_dependencies: [PyYAML]

  - repo: local
    hooks:
      - id: check-no-h-files
        name: No .h files
        entry: There should be no .h files in this repository
        language: fail
        files: \.h$

  - repo: local
    hooks:
      - id: gofmt
        name: Go Format
        entry: pre-commit-hooks/run-go-fmt.sh
        types: [go]
        language: golang
        description: "Runs `gofmt`, requires golang"
      - id: check-docs
        name: Check Doxygen Documentation
        entry: pre-commit-hooks/check-doxygen-docs.sh
        types: [text]
        language: script
        pass_filenames: false
      - id: verify-commits
        name: Verify Commits
        entry: pre-commit-hooks/verify-commits.sh
        always_run: true
        stages: [pre-push]
        language: script
        pass_filenames: false
