我正在使用这个库来尝试向我的项目添加一个预提交挂钩。需要考虑的内容很多,我认为我想要的预提交检查不需要他们的大多数示例使用的大范围。我想做的就是运行一个 python 文件。根据该文件是否退出/完成而没有问题(IE 没有引发异常)是我想要允许或禁止提交的内容。我做了一个.pre-commit-config.yaml
,但我不知道如何让它只运行一个文件。
我基本上希望键入git commit -m "whatever"
自动运行python myfile.py
<- 并基于此退出代码,允许或阻止提交。关于我的 yaml 应该是什么样子的任何想法?
这是我到目前为止所拥有的:
repos:
- repo: local
hooks:
- id: translation-file-check
name: Check Translation Files Are Aligned
description: This hook ensures that all translation files share the same set of keys and generates a CSV if there are no issues
language: python
entry: "./dir/subdir/myfile.py"
但我收到以下错误:.An unexpected error has occurred: OSError: [WinError 193] %1 is not a valid Win32 application
我认为因为它期望这个 .py 文件是一个 .exe 或其他东西,即使我设置language
为 python ...