所以在我的项目中,有几个预提交挂钩来确保我们的代码符合团队标准,但每当我尝试提交更改时,总是会出现一个错误,说找不到可执行文件。通常,我首先假设PATH环境变量值一定有问题,但这是唯一导致问题的实际gitcommit命令。
yunu@LAPTOP-8FK6RMJ8:/mnt/d/Projects/xyz/idl$ pre-commit
Fix End of Files.........................................................Passed
Trim Trailing Whitespace.................................................Passed
yamllint.............................................(no files to check)Skipped
ensure buf...............................................................Passed
buf check lint...........................................................Passed
buf check breaking.......................................................Passed
yunu@LAPTOP-8FK6RMJ8:/mnt/d/Projects/xyz/idl$ git commit
Fix End of Files.........................................................Passed
Trim Trailing Whitespace.................................................Passed
yamllint.............................................(no files to check)Skipped
ensure buf...............................................................Failed
- hook id: ensure-buf
- exit code: 1
Executable `task` not found
buf check lint...........................................................Failed
- hook id: buf-lint
- exit code: 1
Executable `buf` not found
buf check breaking.......................................................Failed
- hook id: buf-breaking
- exit code: 1
Executable `buf` not found
我可以运行据说在这之后找不到的命令
我可以看到bash可以很好地识别这些命令。
yunu@LAPTOP-8FK6RMJ8:/mnt/d/Projects/xyz/idl$ buf
Usage:
buf [command]
Available Commands:
check Run lint or breaking change checks.
experimental Experimental commands. Unstable and will likely change.
help Help about any command
image Work with Images and FileDescriptorSets.
ls-files List all Protobuf files for the input location.
protoc High-performance protoc replacement.
Flags:
-h, --help help for buf
--log-format string The log format [text,color,json]. (default "color")
--log-level string The log level [debug,info,warn,error]. (default "info")
--timeout duration The duration until timing out. (default 2m0s)
-v, --version version for buf
Use "buf [command] --help" for more information about a command.
yunu@LAPTOP-8FK6RMJ8:/mnt/d/Projects/xyz/idl$
那么问题出在哪里呢?git命令使用不同类型的PATH吗?
我在windows 10上的ubuntu wsl上运行这个。
在我删除.git/hooks/pre-commit并再次运行pre-commit-install后,问题得到了解决。现在我可以使用git-commit命令而不会遇到麻烦。
对我来说,我所要做的就是重新启动PyCharm
我在VScode上一次又一次地得到同样的错误;我最终使用了hadolint dockerfile而不是
所以在我的pre-commit-config.yaml
中我有
- repo: local
hooks:
- id: hadolint
name: hadolint
entry: hadolint/hadolint:v2.12.1-beta hadolint --ignore DL3008 --no-color
language: docker_image
types: [file, dockerfile]