我有一个预提交,并且我想在其中添加一个预推送 Hook 。 因此,当我推送我的更改时,我只想启动仅 python 测试 (pytest),而不是所有钩子(Hook)(flake8、black 等)。
这是我的预提交配置:
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
请问我该怎么做?
最佳答案
您已找到 the right option -- 你只是配置错误了!
-default_stages: [commit, push]
+default_stages: [commit]
免责声明:我创建了预提交
关于git - pytest 仅在推送时使用预提交 Hook 进行测试,而不是在提交时进行测试,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/73637819/