Environment and development tools: Difference between revisions

Jump to navigation Jump to search
m
Tag: 2017 source edit
Tag: 2017 source edit
Line 71: Line 71:


=== Install Pre-commit git hook ===
=== Install Pre-commit git hook ===
Go to '''/dev/setup/git/hooks''' of your local repository, copy the file '''pre-commit''' into the '''.git/hooks''' folder of your local repository and make it executable.
You can use git hooks to check the syntax of the file you commit and cancel the commit if something is wrong. If you have phpcs and phpcbf installed, you can also files the files automatically. This is how to:


If not install, install phpcs.
Go to '''/dev/setup/git/hooks''' of your local repository, copy the file '''pre-commit''' into a '''.git/hooks''' folder of the local git repository and make it executable.


Next, you need to edit pre-commit file in .git/hooks to modify the lines 40 and 48 of the file to the path of your phpcs and phpcbf install.
Next, you need to edit pre-commit file in .git/hooks to modify the DIRPHPCS variable to set the path of your phpcs and phpcbf tool (you can keep them empty if tools ara available into your PATH).


Once installed, the hook will start on your next commit to re-format your code, so your code will always match the coding syntax rules. If everybody enable this hook, everybody will use the same coding syntax rule, so it is highly recommended to enable it if you can.
Once installed, the hook will start on your next commit to re-format your code, so your code will always match the coding syntax rules. If everybody enable this hook, everybody will use the same coding syntax rule, so it is highly recommended to enable it if you can.

Navigation menu