# 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

repos:
  # Standard hooks
  - repo: https://github.com/pre-commit/pre-commit-hooks
    rev: v4.1.0
    hooks:
      - id: check-added-large-files
      - id: check-case-conflict
      - id: check-executables-have-shebangs
      - id: check-docstring-first
      - id: check-merge-conflict
      - id: check-shebang-scripts-are-executable
      - id: check-symlinks
      - id: check-vcs-permalinks
      - id: check-xml
      - id: check-yaml
        exclude: mobipick_description/config/joint_limits.yaml
      - id: debug-statements
      - id: end-of-file-fixer
        exclude: &excludes |
          (?x)^(
              .*\.blend|
              .*\.dae|
              .*\.mtl|
              .*\.obj|
              .*\.pgm|
              .*\.step|
              .*\.stl
          )$
      - id: fix-byte-order-marker
      - id: mixed-line-ending
        exclude: *excludes
      - id: trailing-whitespace
        exclude: *excludes

  - repo: https://github.com/psf/black
    rev: 22.3.0
    hooks:
      - id: black

  - repo: https://github.com/PyCQA/flake8.git
    rev: 5.0.4
    hooks:
    - id: flake8

  - repo: https://github.com/detailyang/pre-commit-shell.git
    rev: v1.0.6
    hooks:
    - id: shell-lint
      args: [--external-sources]

  - repo: https://github.com/markdownlint/markdownlint
    rev: v0.11.0
    hooks:
    - id: markdownlint

  - repo: https://github.com/pryorda/dockerfilelint-precommit-hooks
    rev: v0.1.0
    hooks:
    - id: dockerfilelint

  - repo: https://github.com/Lucas-C/pre-commit-hooks
    rev: v1.3.1
    hooks:
      - id: insert-license
        files: \.py$
        exclude: |
          (?x)^(
              .*setup\.py|
              .*__init__\.py|
              .*test_copyright\.py|
              .*test_pep257\.py|
              mir_driver/nodes/tf_remove_child_frames\.py|
              mir_navigation/mprim/genmprim_unicycle_highcost_5cm\.py
          )$
        args:
          - --license-filepath
          - LICENSE

  - repo: https://github.com/pycqa/pydocstyle
    rev: 6.1.1
    hooks:
      - id: pydocstyle
        args:
        - --ignore=D100,D101,D102,D103,D104,D105,D106,D107,D203,D212,D404   # same as https://github.com/ament/ament_lint/blob/bbdaa17224f3b8dfece53662b65d7d18b7404b6a/ament_pep257/ament_pep257/main.py#L43-L55

  - repo: local
    hooks:
      - id: clang-format
        name: clang-format
        description: Format files with ClangFormat.
        entry: clang-format-10
        language: system
        files: \.(c|cc|cxx|cpp|frag|glsl|h|hpp|hxx|ih|ispc|ipp|java|js|m|proto|vert)$
        args: [ "-fallback-style=none", "-i" ]
      - id: catkin_lint
        name: catkin_lint
        description: Check package.xml and cmake files
        entry: catkin_lint .
        language: system
        always_run: true
        pass_filenames: false
        args: [ "--strict", "--skip-pkg", "mobipick_moveit_config" ]   # have to skip this package because of the missing warehouse_ros_mongo dependency
