我使用一些buf的预要挂钩来帮助我检查Protobuf文件,然后再编译它们以进行:
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0 # Use the ref you want to point at
hooks:
# Git style
- id: check-added-large-files
args: ["--maxkb=512"]
- id: check-merge-conflict
- id: check-vcs-permalinks
- id: forbid-new-submodules
# Common errors
- id: end-of-file-fixer
- id: check-yaml
args: [--allow-multiple-documents]
- id: check-merge-conflict
- id: check-executables-have-shebangs
# Cross platform
- id: check-case-conflict
- repo: https://github.com/yoheimuta/protolint
rev: v0.53.0
hooks:
- id: protolint
files: protos/.
- repo: https://github.com/python-jsonschema/check-jsonschema
rev: 0.23.3
hooks:
- id: check-github-workflows
- repo: https://github.com/bufbuild/buf
rev: v1.50.1
hooks:
- id: buf-dep-update
- id: buf-dep-prune
- id: buf-breaking
args: ["--against", ".git/subdir=start/protos"]
我不确定为什么,但是当我本地运行此操作时,我总是会收到以下错误消息:
发生意外错误:essertionError:目前,预先承诺需要系统安装的Golang我可以说这是在BUF预先承诺挂钩上发生的,因为我可以将其删除并且该过程正确地运行。但是,我确实已经安装了:
> go version
go version go1.24.1 linux/amd64
> which go
/usr/local/go/bin/go
由于没有安装在主目录中,我看不出这是不起作用的。它确实在github上正确运行。我如何才能使此预签订的挂钩正确运行?
钩子的一个钩子设置为一定的值。
go
(发布2023-01-23)
the disclaimer:我写了预先竞争的