Post Reply 
 
Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Git hooks
06-30-2019, 06:50 PM
Post: #1
Git hooks
Here is an archive of my git hook scripts as promised in this thread (http://www.weberp.org/forum/showthread.p...pid15774). 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 convert_line_endings_to_unix.sh 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 check_white_space.sh 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 check_variable_names.sh 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 format_code.sh which uses an amended version of PHP beautifier (https://pear.php.net/package/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 syntax.sh 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.

Tim


.gz  hooks.tar.gz (Size: 9.21 KB / Downloads: 1)
Visit this user's website Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
Git hooks - falkoner - 06-30-2019 06:50 PM
RE: Git hooks - falkoner - 07-02-2019, 07:21 AM

Forum Jump:


User(s) browsing this thread: 1 Guest(s)