Handle multiple pre-commit hooks

karthik101 picture karthik101 · Oct 29, 2014 · Viewed 11.5k times · Source

I have a need to use multiple pre-commit hook scripts. Not sure how to handle them. Should all of them be combined into one single large pre-commit script ? if not, how to handle multiple pre-commit scripts ?

Answer

VonC picture VonC · Oct 29, 2014

Should all of them be combined into one single large pre-commit script ?

Yes and no: you can only declare one pre-commit script, so this script should be in charge to:

  • call the actual pre-commit scripts
  • chose an order for those scripts to be called.

So:

  • one pre-commit script
  • calling multiple scripts, each one allowing or not (with their exit status) the commit to proceed.