# NOTE: The versions can be updated by calling
#        pre-commit autoupdate
repos:
  - repo: https://github.com/pre-commit/pre-commit-hooks
    rev: v4.4.0
    hooks:
      - id: check-json
      - id: check-yaml
      - id: check-merge-conflict
      - id: debug-statements
      - id: check-added-large-files
      - id: no-commit-to-branch
        args: [--branch, master, --branch, main]
      - id: end-of-file-fixer
      - id: mixed-line-ending
        args: ["--fix=lf"]
      - id: trailing-whitespace
  - repo: https://github.com/psf/black
    rev: 22.12.0
    hooks:
      - id: black
        args: [--line-length, "120"]
      - id: black-jupyter
        files: '.*\.ipynb'
  - repo: https://github.com/asottile/blacken-docs
    rev: 1.13.0
    hooks:
      - id: blacken-docs
        additional_dependencies:
          - black==22.12.0
  - repo: https://github.com/ssciwr/clang-format-hook
    rev: v15.0.6
    hooks:
      - id: clang-format
        args: [-i]
        # Exclude protobuff files
        exclude: '^(.*pb\.h)|(.*pb\.cc)$'
  - repo: local
    hooks:
      - id: copyright-header-check
        name: Copyright header check
        description: Ensures that files have the proper copyright line at the top
        entry: python3 -m examples_utils test_copyright --amend --exclude_json utils/examples_tests/copyright_header_test_exclude.json
        pass_filenames: false
        language: python
        additional_dependencies:
          - "git+https://github.com/graphcore/examples-utils@f8673d362fdc7dc77e1fee5f77cbcd81dd9e4a2e"
      - id: trademark-linter
        name: Trademark linter
        description: Ensures that files have the proper trademark line.
        entry: python3 -m utils.linters.trademark.trademark
        language: python
      - id: notebook-cleaner
        name: Notebook cleaner
        description: Removes metadata from Jupyter notebook cells to keep upstream clean.
        entry: python3 -m utils.linters.notebook_cleaner.notebook_cleaner
        language: python
        additional_dependencies:
          - nbconvert
  - repo: https://github.com/codespell-project/codespell
    rev: v2.2.4
    hooks:
      - id: codespell
