"Define a pre-commit hook" was removed from development.md
The chapter Define a pre-commit hook was removed from development.md in #661. But I don't see the reason why to do this. pre-commit is useful and we should keep the guide.
/cc @alexandercampbell
This also breaks https://github.com/kubernetes/community/blob/master/contributors/devel/pull-requests.md#run-local-verifications
cc @pwittrock
@xiangpengzhao regarding the broken link: sorry, I should have also removed the link as part of the same PR.
pre-commitis useful and we should keep the guide.
I deleted the pre-commit section of the doc because nobody I've talked to used it and I didn't believe that any developer would be willing to use it. It's painfully slow. Even on my powerful desktop it takes nearly eight minutes.
% time ./hooks/pre-commit
... snip ...
1930.24user
155.51system
7:51.21elapsed
If you did a rebase to reword four commits, you'd spent about 30 minutes doing nothing.
I'm willing to re-add a reference to the pre-commit hook. I don't want to recommend it as standard practice because everyone will immediately disable on their second or third commit.
/assign
@alexandercampbell: GitHub didn't allow me to assign the following users: alexandercampbell.
Note that only kubernetes members can be assigned.
In response to this:
/assign
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.
Heh, nice. @pwittrock when you see this, can you assign me to this issue?
@xiangpengzhao Thanks for filing this. Do you use precommit? I have found it to be frequently broken for Mac development, and disabled it some time ago.
Thanks @alexandercampbell @pwittrock ! TBH, I skip pre-commit in most of commits, especially for trivial ones. It's indeed slow. But for those commits which need to auto generate files, the hook is useful, at least for me. It helps verify what should be auto generated. Surely we can leave the verifacation to CI, but CI is much slower than the hook.
IMO, we might not want to recommend pre-commit to developers, but we should provide the way how to setup hook if they do want it.
@xiangpengzhao
Ok, I see what you're saying. The pre-commit is useful, but not as a pre-commit. It's more like a pre-pull-request check. Maybe we should move the script into hack/pre-pull-request.sh or something like that?
Agreed.
See
- https://github.com/kubernetes/kubernetes/pull/47673
- https://github.com/kubernetes/community/pull/730
To comment here as well (from https://github.com/kubernetes/kubernetes/pull/47673#issuecomment-309118930):
I'm not even sure we still should have this. This basically runs a small subset of
make verify. Perhaps we should just remove this entirely and update docs to suggest usingmake verifylocally prior to push.
I like that solution. @xiangpengzhao thoughts?
https://github.com/kubernetes/kubernetes/pull/47673#issuecomment-309172057
Does make verify do the same things, or more, or less? I remembered that it runs longer time than pre-commit. It also doesn't make the binaries, right? I don't know if this is just what I want...I'm on the fence. If most folks think pre-commit as useless, I will agree to remove it.
https://github.com/kubernetes/community/pull/730 was merged, and https://github.com/kubernetes/kubernetes/pull/47673 is approved to be merged.
Thanks to all! Closing..