Python 如何正确配置预提交和预推钩子?
我有一个简单的python项目,目前只有一个文件。它存在于我的项目的static/cgi-bin文件夹中。目前,在我的目录的底部,有一个.pre-commit-config.yaml文件,我还没有接触到.git/hooks文件夹中的文件。我想创建预提交和预推钩子,但我似乎无法让它工作 当我尝试提交时,会发生以下情况:Python 如何正确配置预提交和预推钩子?,python,pre-commit-hook,pre-commit.com,Python,Pre Commit Hook,Pre Commit.com,我有一个简单的python项目,目前只有一个文件。它存在于我的项目的static/cgi-bin文件夹中。目前,在我的目录的底部,有一个.pre-commit-config.yaml文件,我还没有接触到.git/hooks文件夹中的文件。我想创建预提交和预推钩子,但我似乎无法让它工作 当我尝试提交时,会发生以下情况: isort................................................(no files to check)Skipped flake8....
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]
预提交将向列出的条目传递一个列表
提交中没有显示要检查的文件,因为提交中没有python文件。在首次引入新挂钩时,您可能希望运行预提交运行所有文件
对于pytest钩子,pytest在未运行任何测试时退出非零,因此失败。预提交将向列出的条目传递一个列表
提交中没有显示要检查的文件,因为提交中没有python文件。在首次引入新挂钩时,您可能希望运行预提交运行所有文件
至于pytest钩子,pytest在不运行任何测试时退出非零,因此失败。我认为您正在使用这里,这只是定义git钩子的众多方法之一。如果是这样的话,你能澄清一下你的问题吗?请在我想你正在使用的网站上获取一些关于本地git钩子的信息,这只是定义git钩子的众多方法之一。如果是这样的话,你能澄清你的问题吗?请在