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

Add .pre-commit-hooks.yaml #311

Merged
merged 1 commit into from
Dec 22, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 7 additions & 0 deletions .pre-commit-hooks.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
- id: golangci-lint
name: golangci-lint
description: Fast linters runner for Go.
entry: golangci-lint run
types: [go]
language: golang
pass_filenames: false
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think should support passing filenames, right? Otherwise this won't have the ability to do somewhat incremental diffs.

Separately, it would be nice to pass the sha and only do incremental diffs on a per-commit basis. I know golangci-lint supports this, but I don't think pre-commit does.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While that's true, golangci-lint AFAIK expects go package directories, not filenames, and I'm not sure whether a wrapper script here in golangci-lint, or a converter in pre-commit (since other Go tools are likely to use the same convention) is better.

pre-commit can be smart about only checking staged files during an actual pre-commit hook, but I haven't thought about how to integrate that with golangci-lint; fixing the pass_filenames thing would be a good first step there.

I'd like to get this in as a basic implementation first, and then refine it to get the improved performance/benefits of incremental linting afterwards since that will require a bit of design work.