我目前有一个带有单个文件的简单 python 项目。它存在于我项目的 static/cgi-bin 文件夹中。目前,在我的目录的基础上,我有一个 .pre-commit-config.yaml 文件,我还没有触及 .git/hooks 文件夹中的文件。我想创建预提交和预推送钩子,但我似乎无法让它工作。
当我尝试提交时,会发生以下情况:
isort................................................(no files to check)Skipped
flake8...............................................(no files to check)Skipped
black................................................(no files to check)Skipped
当我尝试推送时,出现以下错误:
pytest...................................................................Failed
hookid: pytest
============================= test session starts ==============================
platform darwin -- Python 2.7.15, pytest-4.0.2, py-1.7.0, pluggy-0.8.0
rootdir: /Users/.../deployment, inifile:
collected 0 items
========================= no tests ran in 0.01 seconds =========================
error: failed to push some refs to '...git'
请注意,部署是我正在使用的文件夹。
我在 yaml 文件中的代码是:
repos:
- repo: local
hooks:
- id: isort
name: isort
entry: isort
language: system
types: [python]
stages: [commit]
- id: flake8
name: flake8
language: system
entry: flake8
types: [python]
stages: [commit]
- id: black
language_version: python3.6
name: black
language: system
entry: black
types: [python]
stages: [commit]
- id: pytest
name: pytest
language: system
entry: pytest
pass_filenames: false
always_run: true
stages: [push]