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

Conversation

aneeshusa
Copy link
Contributor

This file will allow using golangci-lint with https://pre-commit.com.

Thank you for the pull request!

Please make sure you didn't directly change README.md: it should be changed only by changing README.tmpl.md and running make readme.

This file will allow using golangci-lint with https://pre-commit.com.
@CLAassistant
Copy link

CLAassistant commented Dec 3, 2018

CLA assistant check
All committers have signed the CLA.

@aneeshusa
Copy link
Contributor Author

This is to fix #284. cc @nexeck

@aneeshusa
Copy link
Contributor Author

cc @diegs

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.

@diegs
Copy link
Contributor

diegs commented Dec 4, 2018

@aneeshusa LGTM, though I have no access to this repo to grant any real approvals :)

@jirfag jirfag merged commit e72fe05 into golangci:master Dec 22, 2018
@jirfag
Copy link
Member

jirfag commented Dec 22, 2018

thank you for the pull request!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: pre-commit enhancement New feature or improvement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants