santhosh-tekuri/jsonschema

pre-commit hook

Closed this issue · 4 comments

Hi,

Are you open to provide a .pre-commit-hooks.yaml to use the jv CLI inside pre-commit ?

Thanks !

I am not sure of how to do it. If you like to contribute, I will be happy

Cool ! I don't have much time now but I'll check if the subject has attraction and I can find some time.

There is this PR from golangci-lint repo that can be used as an example : https://github.com/golangci/golangci-lint/pull/311/files
But I'm not sure how pre-commit is able to find the binary.

From the pre-commit docs here:

The hook repository must contain go source code. It will be installed via go install ./....
pre-commit will create an isolated GOPATH for each hook and the entry should match an executable which will get installed into the GOPATH's bin directory.

When I clone this repo and do go install ./... from the root, nothing new shows up in my $GOBIN directory.
This seems to be because cmd/jv/go.mod exists and the main.go file there in that directory is inside a different Go module.

With that cmd/jv/go.mod removed, the barebones .pre-commit-hooks.yaml file would start from something like this:

id: jsonschema-validate
name: Validate JSON against JSON Schema
entry: jv
language: golang

More details on fields for the above YAML are here.

fixed in v6.0.0