Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pre-commit hook #108

Open
gnuletik opened this issue Mar 8, 2023 · 3 comments
Open

pre-commit hook #108

gnuletik opened this issue Mar 8, 2023 · 3 comments

Comments

@gnuletik
Copy link

gnuletik commented Mar 8, 2023

Hi,

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

Thanks !

@santhosh-tekuri
Copy link
Owner

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

@gnuletik
Copy link
Author

gnuletik commented Mar 8, 2023

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.

@jlucktay
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants