jsonschema icon indicating copy to clipboard operation
jsonschema copied to clipboard

pre-commit hook

Open gnuletik opened this issue 2 years ago • 3 comments
trafficstars

Hi,

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

Thanks !

gnuletik avatar Mar 08 '23 10:03 gnuletik

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

santhosh-tekuri avatar Mar 08 '23 10:03 santhosh-tekuri

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.

gnuletik avatar Mar 08 '23 17:03 gnuletik

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.

jlucktay avatar Oct 10 '23 14:10 jlucktay

fixed in v6.0.0

santhosh-tekuri avatar Jun 04 '24 17:06 santhosh-tekuri