git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] add a 'pre-push' hook

From
Jeff King <peff@peff.net>
Date
Aug 19, 2008, 19:08 UTC
Message-ID
<20080819190832.GC17943@coredump.intra.peff.net>
In-Reply-To
<d411cc4a0808191200o39837fd0ka2530aed870e06b0@mail.gmail.com>
On Tue, Aug 19, 2008 at 12:00:38PM -0700, Scott Chacon wrote:
> If the patch is acceptable, I will update the githooks doc with more
> information, but we would like this so that you could add a hook that
> runs your automated tests before a push would go through.

I think the common wisdom has been that such tests should be done on the _receiving_ end, since that makes a more trustworthy enforcement point. E.g., I know that crap can't get into my central repo because a hook checks everything coming in. But if a developer has turned off his pre-push hook (or accidentally failed to enable it), he can still send crap.

One other argument I have seen is that, to prevent the proliferation of hooks, the rule is not to add a hook that could just as easily be done as a sequence of commands. IOW, what's wrong with

  run_my_automated_tests && git push
?

Off the top of my head, I guess the response to those two arguments would be:

 - sometimes the receiving end isn't set up to run tests, which means it
   is more reasonable to do it on the sending side
 - it's more convenient to just type "git push" than to remember "tests
   && git push", so this reduces the chances of contributors
   accidentally pushing crap
-Peff
Previous: Scott ChaconNext: Shawn O. Pearce
Message 4 of 15 in “add a 'pre-push' hook”
  1. add a 'pre-push' hookScott Chacon, Aug 19, 2008
  2. Jeff KingAug 19, 2008
  3. Scott ChaconAug 19, 2008
  4. Jeff KingAug 19, 2008
  5. Shawn O. PearceAug 19, 2008
  6. Scott ChaconAug 19, 2008
  7. しらいしななこAug 19, 2008
  8. Scott ChaconAug 19, 2008
  9. Junio C HamanoAug 19, 2008
  10. Sam VilainAug 19, 2008
  11. Jeff KingAug 20, 2008
  12. Junio C HamanoAug 19, 2008
  13. Scott ChaconAug 19, 2008
  14. Junio C HamanoAug 19, 2008
  15. Shawn O. PearceAug 19, 2008

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.