community icon indicating copy to clipboard operation
community copied to clipboard

"Define a pre-commit hook" was removed from development.md

Open xiangpengzhao opened this issue 9 years ago • 15 comments

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

xiangpengzhao avatar Jun 16 '17 07:06 xiangpengzhao

This also breaks https://github.com/kubernetes/community/blob/master/contributors/devel/pull-requests.md#run-local-verifications

xiangpengzhao avatar Jun 16 '17 07:06 xiangpengzhao

cc @pwittrock

@xiangpengzhao regarding the broken link: sorry, I should have also removed the link as part of the same PR.

pre-commit is 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.

alexandercampbell avatar Jun 16 '17 16:06 alexandercampbell

/assign

alexandercampbell avatar Jun 16 '17 16:06 alexandercampbell

@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.

k8s-ci-robot avatar Jun 16 '17 16:06 k8s-ci-robot

Heh, nice. @pwittrock when you see this, can you assign me to this issue?

alexandercampbell avatar Jun 16 '17 16:06 alexandercampbell

@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.

pwittrock avatar Jun 16 '17 16:06 pwittrock

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.

xiangpengzhao avatar Jun 16 '17 17:06 xiangpengzhao

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 avatar Jun 16 '17 17:06 xiangpengzhao

@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?

alexandercampbell avatar Jun 16 '17 17:06 alexandercampbell

Agreed.

xiangpengzhao avatar Jun 16 '17 17:06 xiangpengzhao

See

  1. https://github.com/kubernetes/kubernetes/pull/47673
  2. https://github.com/kubernetes/community/pull/730

alexandercampbell avatar Jun 16 '17 19:06 alexandercampbell

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 using make verify locally prior to push.

cblecker avatar Jun 16 '17 19:06 cblecker

I like that solution. @xiangpengzhao thoughts?

alexandercampbell avatar Jun 16 '17 19:06 alexandercampbell

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.

xiangpengzhao avatar Jun 17 '17 00:06 xiangpengzhao

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..

cblecker avatar Jun 21 '17 19:06 cblecker