Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Git hooks
06-30-2019, 06:50 PM,
Git hooks
Here is an archive of my git hook scripts as promised in this thread ( They need to be placed in the .git directory of your local repository. They work OK in all versions of Linux we have tried them on. I don't possess a Windows box, or a Mac box. They are all either bash scripts, or PCP-CLI scripts (yes I know but it was just easier at the time!) and so the first line in each script should point to the respective binary.

The prepare-commit-msg script was written by my colleague Juergen Mueller and overrides the standard commit message format to what we think is a better layout.
The pre-commit script runs several sub scripts before the code can be committed. These all enforce coding policies on the scripts being committed, or check for syntax errors. If any of these scripts fail, then the commit is aborted with a (hopefully) sensible error message allowing you to track the problem.
The first of these is which uses the dos2unix utility to ensure that line endings are consistently of the unix style rather than the dos style - Git can behave strangely with the dos style line endings.
The second is which does a few things to rationalise the use of white space, such as removing trailing white space from lines, it removes unnecessary tabs from css files etc.
The next is which enforces commonly used variables to a certain style. All instances of $sql, $result, $myrow, $pdf are changed to $SQL, $Result, $MyRow, $PDF for consistency with the rest of the code.
Then we have which uses an amended version of PHP beautifier ( to format the code to conform with the old coding guidelines. If anybody is interested I can help with amending PHP beautifier. I think as well paths on my machine are hard coded in these scripts so beware Smile
Finally there is which uses php -l to check the syntax of the scripts being committed.

Please feel free to use some or any of these hooks if they are of interest.


.gz   hooks.tar.gz (Size: 9.21 KB / Downloads: 1)
07-02-2019, 07:21 AM,
RE: Git hooks
If it is of any interest to anybody I have put them on GitHub

Forum Jump:

Users browsing this thread: 1 Guest(s)