-
-
Notifications
You must be signed in to change notification settings - Fork 315
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 config #188
base: master
Are you sure you want to change the base?
Conversation
added `.pre-commit-config.yaml` to the repo. To use it: - `pip install pre-commit` - Install the following Go packages: * go install github.com/go-critic/go-critic/cmd/gocritic@latest * go install https://pkg.go.dev/golang.org/x/tools/cmd/goimports@latest * go install golang.org/x/lint/golint@latest - In your clone, run: `pre-commit install` This will create .git/hooks/pre-commit and following that, these tests will run every time you invoke `git commit`: ```sh go fmt...................................................................Passed go imports...............................................................Passed go vet...................................................................Passed go lint..................................................................Passed go-critic................................................................Passed ```
Hello, Just wondering whether you'd like to merge this? Cheers, |
Hey @jessp01, sorry I missed this when you opened it. Thanks for the PR! Could you say a word or two about what extra value you intend for this to add to the repo? For example, |
Hi @bitfield , This does not replace a proper CI, of course, since you can't enforce the use of these prehooks in the clone commits are made in; in other words: you need to trust the developers to install the hooks:) It's great to use an IDE that integrates plugins that check for formatting/linting and import issues but, you can't be sure that all contributors to the project do the same and I do think there's value in offering ready-made prehooks that check for such issues and blocks commits that introduce them, regardless of the IDE used. |
Yes, I see your point that a pre-commit hook is opt-in, and that if you want to actually enforce things like |
Hi @bitfield , I've added invocations of the pre-commit hooks (the term "pre-commit hooks" obviously does not apply at this stage but you get my drift) in the CI (and changed the stage name accordingly so it reflects them). I've also added usage info in the README. Let me know what you think? Cheers, |
I think there's something I'm not quite understanding here: if you want to run, for example, I guess I'm not seeing what value |
Hi @bitfield , You wrote:
From which, I understood that you wanted me to add these checks to the CI:) |
Yes, I see, sorry—that's on me for wording my suggestion too vaguely. By "these checks" I meant formatting, linting, and so on. As I say, I think running them directly, rather than via What would you think about using gofumpt instead of vanilla |
Added
.pre-commit-config.yaml
to the repo. To use it:pip install pre-commit
pre-commit install
This will create .git/hooks/pre-commit and following that, these tests will run every time you invoke
git commit
: