Multi stage config is not fully installed from single 'pre-commit install'
See original GitHub issueI’d like to use pre-commit and pre-push hooks. As I try to keep commit-time low, I’d like to only perform a subset before the commit stage and the full set before the push stage. I can create a .pre-commit-config.yaml
that contains all hooks and use the stages
keyword, to assign which hooks should be run at which stage. If I’m not mistaken, I’ll need to run pre-commit install
twice, once per stage though.
Is there currently an option that allows easy installation (i.e. run pre-commit install
once without options) and have all hooks installed according to the specification in the config file? This would also make the automatic enabling in new repositories easier, unless that already takes care of such cases somehow.
Here is a minimal example for the .pre-commit-config.yaml
with one hook run only before commits and one only before pushes:
default_stages: [commit]
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v3.2.0
hooks:
- id: check-merge-conflict
- id: trailing-whitespace
stages: [push]
You’ve said somewhere else, that you would prefer not to change the default behavior of install (because some users might actively use separate installs for different stages). But perhaps, adding a --all
or --all-stages
flag could solve the issue?
Issue Analytics
- State:
- Created 3 years ago
- Reactions:2
- Comments:6 (4 by maintainers)
Top GitHub Comments
init-templatedir
takes the same arguments asinstall
so the solution is the same stillnotably
pre-commit init-templatedir whatever --hook-stage commit --hook-stage push ...