I've a pre-commit, and I want to add a pre-push hook within. So, I want to launch only python tests (pytest) when I push my changes, and not all the hooks (flake8, black, etc).
Here my pre-commit config :
default_stages: [commit, push]
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v3.2.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-yaml
- id: check-added-large-files
args: [ "--maxkb=120000" ]
- id: check-json
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v2.3.0
hooks:
- id: flake8
- repo: https://github.com/psf/black
rev: 22.3.0
hooks:
- id: black
language_version: python3.9
- repo: https://github.com/pre-commit/mirrors-jshint
rev: v2.9.7
hooks:
- id: jshint
- repo: https://github.com/pre-commit/mirrors-scss-lint
rev: v0.57.1-1
hooks:
- id: scss-lint
- repo: https://github.com/asottile/reorder_python_imports
rev: v1.7.0
hooks:
- id: reorder-python-imports
- repo: local
hooks:
- id: pytest-check
stages: [push]
types: [python]
name: pytest-check
entry: python -m pytest -v tests/
language: system
pass_filenames: false
always_run: true
How can I do that please ?
you've found the right option -- you've just misconfigured it !
-default_stages: [commit, push]
+default_stages: [commit]
disclaimer: I created pre-commit