---
minimum_pre_commit_version: 1.15.2
repos:
  - repo: https://github.com/pre-commit/pre-commit-hooks
    rev: v2.1.0
    hooks:
      - id: check-merge-conflict  # Check for files that contain merge conflict strings.
      - id: trailing-whitespace   # Trims trailing whitespace.
        args: [--markdown-linebreak-ext=md]
      - id: mixed-line-ending     # Replaces or checks mixed line ending.
        args: [--fix=lf]
      - id: end-of-file-fixer     # Makes sure files end in a newline and only a newline.
      - id: check-merge-conflict  # Check for files that contain merge conflict strings.
      - id: check-ast             # Simply check whether files parse as valid python.

  # ----- Formatting ---------------------------------------------------------------------------->
  - repo: https://github.com/saltstack/pre-commit-remove-import-headers
    rev: 1.0.0
    hooks:
      - id: remove-import-headers

  - repo: https://github.com/asottile/pyupgrade
    rev: v2.7.2
    hooks:
      - id: pyupgrade
        name: Rewrite Code to be Py3.5+
        args: [--py3-plus]
        exclude: src/saltext/{{ project_package }}/version.py

  - repo: https://github.com/asottile/reorder_python_imports
    rev: v2.3.5
    hooks:
      - id: reorder-python-imports
        args: [
          --py3-plus,
        ]
        exclude: src/saltext/{{ project_package }}/version.py

  - repo: https://github.com/psf/black
    rev: 20.8b1
    hooks:
      - id: black
        args: [-l 100]
        language_version: python3.6
        exclude: src/saltext/{{ project_package }}/version.py

  - repo: https://github.com/asottile/blacken-docs
    rev: v1.7.0
    hooks:
      - id: blacken-docs
        args: [--skip-errors]
        files: ^docs/.*\.rst
        additional_dependencies: [black==20.8b1]
  # <---- Formatting -----------------------------------------------------------------------------

  # ----- Code Analysis ------------------------------------------------------------------------->
  - repo: https://github.com/saltstack/mirrors-nox
    rev: v2020.8.22
    hooks:
      - id: nox
        alias: lint-src
        name: Lint Source Code
        files: ^((setup|noxfile)|src/.*)\.py$
        args:
          - -e
          - lint-code-pre-commit
          - --

  - repo: https://github.com/saltstack/mirrors-nox
    rev: v2020.8.22
    hooks:
      - id: nox
        alias: lint-tests
        name: Lint Tests
        files: ^tests/.*\.py$
        args:
          - -e
          - lint-tests-pre-commit
          - --
  # <---- Code Analysis --------------------------------------------------------------------------

  # ----- Static Test Requirements -------------------------------------------------------------->
  - repo: https://github.com/saltstack/pip-tools-compile-impersonate
    rev: master
    hooks:
      - id: pip-tools-compile
        alias: compile-3.5-test-requirements
        name: Py3.5 Test Requirements
        files: ^requirements/tests.in$
        pass_filenames: false
        args:
          - -v
          - --py-version=3.5
          - --platform=linux
          - requirements/tests.in

  - repo: https://github.com/saltstack/pip-tools-compile-impersonate
    rev: master
    hooks:
      - id: pip-tools-compile
        alias: compile-3.6-test-requirements
        name: Py3.6 Test Requirements
        files: ^requirements/tests.in$
        pass_filenames: false
        args:
          - -v
          - --py-version=3.6
          - --platform=linux
          - requirements/tests.in

  - repo: https://github.com/saltstack/pip-tools-compile-impersonate
    rev: master
    hooks:
      - id: pip-tools-compile
        alias: compile-3.7-test-requirements
        name: Py3.7 Test Requirements
        files: ^requirements/tests.in$
        pass_filenames: false
        args:
          - -v
          - --py-version=3.7
          - --platform=linux
          - requirements/tests.in

  - repo: https://github.com/saltstack/pip-tools-compile-impersonate
    rev: master
    hooks:
      - id: pip-tools-compile
        alias: compile-3.8-test-requirements
        name: Py3.8 Test Requirements
        files: ^requirements/tests.in$
        pass_filenames: false
        args:
          - -v
          - --py-version=3.8
          - --platform=linux
          - requirements/tests.in

  - repo: https://github.com/saltstack/pip-tools-compile-impersonate
    rev: master
    hooks:
      - id: pip-tools-compile
        alias: compile-3.9-test-requirements
        name: Py3.9 Test Requirements
        files: ^requirements/tests.in$
        pass_filenames: false
        args:
          - -v
          - --py-version=3.9
          - --platform=linux
          - requirements/tests.in
  # <---- Static Test Requirements ---------------------------------------------------------------

  # ----- Static Lint Requirements -------------------------------------------------------------->
  - repo: https://github.com/saltstack/pip-tools-compile-impersonate
    rev: master
    hooks:
      - id: pip-tools-compile
        alias: compile-3.5-test-requirements
        name: Py3.5 Lint Requirements
        files: ^requirements/lint.in$
        pass_filenames: false
        args:
          - -v
          - --py-version=3.5
          - --platform=linux
          - requirements/lint.in

  - repo: https://github.com/saltstack/pip-tools-compile-impersonate
    rev: master
    hooks:
      - id: pip-tools-compile
        alias: compile-3.6-test-requirements
        name: Py3.6 Lint Requirements
        files: ^requirements/lint.in$
        pass_filenames: false
        args:
          - -v
          - --py-version=3.6
          - --platform=linux
          - requirements/lint.in

  - repo: https://github.com/saltstack/pip-tools-compile-impersonate
    rev: master
    hooks:
      - id: pip-tools-compile
        alias: compile-3.7-test-requirements
        name: Py3.7 Lint Requirements
        files: ^requirements/lint.in$
        pass_filenames: false
        args:
          - -v
          - --py-version=3.7
          - --platform=linux
          - requirements/lint.in

  - repo: https://github.com/saltstack/pip-tools-compile-impersonate
    rev: master
    hooks:
      - id: pip-tools-compile
        alias: compile-3.8-test-requirements
        name: Py3.8 Lint Requirements
        files: ^requirements/lint.in$
        pass_filenames: false
        args:
          - -v
          - --py-version=3.8
          - --platform=linux
          - requirements/lint.in

  - repo: https://github.com/saltstack/pip-tools-compile-impersonate
    rev: master
    hooks:
      - id: pip-tools-compile
        alias: compile-3.9-test-requirements
        name: Py3.9 Lint Requirements
        files: ^requirements/lint.in$
        pass_filenames: false
        args:
          - -v
          - --py-version=3.9
          - --platform=linux
          - requirements/lint.in
  # <---- Static Lint Requirements ---------------------------------------------------------------

  # ----- Static Docs Requirements -------------------------------------------------------------->
  - repo: https://github.com/saltstack/pip-tools-compile-impersonate
    rev: master
    hooks:
      - id: pip-tools-compile
        alias: compile-3.5-test-requirements
        name: Py3.5 Docs Requirements
        files: ^requirements/docs.in$
        pass_filenames: false
        args:
          - -v
          - --py-version=3.5
          - --platform=linux
          - requirements/docs.in

  - repo: https://github.com/saltstack/pip-tools-compile-impersonate
    rev: master
    hooks:
      - id: pip-tools-compile
        alias: compile-3.6-test-requirements
        name: Py3.6 Docs Requirements
        files: ^requirements/docs.in$
        pass_filenames: false
        args:
          - -v
          - --py-version=3.6
          - --platform=linux
          - requirements/docs.in

  - repo: https://github.com/saltstack/pip-tools-compile-impersonate
    rev: master
    hooks:
      - id: pip-tools-compile
        alias: compile-3.7-test-requirements
        name: Py3.7 Docs Requirements
        files: ^requirements/docs.in$
        pass_filenames: false
        args:
          - -v
          - --py-version=3.7
          - --platform=linux
          - requirements/docs.in

  - repo: https://github.com/saltstack/pip-tools-compile-impersonate
    rev: master
    hooks:
      - id: pip-tools-compile
        alias: compile-3.8-test-requirements
        name: Py3.8 Docs Requirements
        files: ^requirements/docs.in$
        pass_filenames: false
        args:
          - -v
          - --py-version=3.8
          - --platform=linux
          - requirements/docs.in

  - repo: https://github.com/saltstack/pip-tools-compile-impersonate
    rev: master
    hooks:
      - id: pip-tools-compile
        alias: compile-3.9-test-requirements
        name: Py3.9 Docs Requirements
        files: ^requirements/docs.in$
        pass_filenames: false
        args:
          - -v
          - --py-version=3.9
          - --platform=linux
          - requirements/docs.in
  # <---- Static Docs Requirements ---------------------------------------------------------------
