Replace the pre-commit
hook with a pre-push
hook and eliminate 'Optional" from the documentation
#19479
sureshjoshi
started this conversation in
Development
Replies: 1 comment
-
Yeah I agree. And people can choose pre-commit like you did pre-push. But the default aught to be pre-push |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
https://www.pantsbuild.org/docs/contributor-setup#step-2-optional-set-up-a-git-hook
In the Pants docs, there is an optional step to add a
pre-commit
hook. We've had discussions on Slack about eliminating the hook altogether, but I'd like to propose an alternate suggestion which I've been using to great success recently.Avoid pre-commit hooks like the plague, but enforce pre-push hooks like... umm... the plague?
The idea is that, no one should care what happens on a developer's machine on each commit - some people commit often, some people frequently - whatever. No one should be punished by waiting for a script to run based on them liking to commit often.
However, once that code needs to go to a shared location (e.g. Github), it should already be formatted, linted, tested (via
changed-since
) as expected to avoid burning any slow Github CI cycles on code that will 100% fail CI when pushed (e.g. extra newline or something).Even though we don't pay for GH CI - we should still be good citizens about not using unnecessary resources if not necessary.
I will say on a private project, enforcing pre-push in lieu of pre-commit reduced useless CI by about 10% and basically no one complains about it slowing down their dev cycles anymore.
Beta Was this translation helpful? Give feedback.
All reactions