Environment and development tools: Difference between revisions

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


=== Install Pre-commit githook ===
=== Install Pre-commit githook ===
You can use git hooks to check the syntax of the file you commit and cancel (or better autofix) the commit if something is wrong. You need '''phpcs''' command line tool for this (sudo apt-get -y install php-codesniffer). If you have '''phpcbf''' installed, you can also fix the files automatically. This is how to:
You can use git hooks to check the syntax of the file you commit and cancel (or better autofix) the commit if something is wrong.  


Into your GIT repository, copy the file '''./dev/setup/git/hooks/pre-commit''' into your '''.git/hooks''' folder of the local git repository and make it executable.
Instruction to install such a precommit hook is available on this file:
 
https://wiki.dolibarr.org/index.php?title=Environment_and_development_tools#Install_Pre-commit_githook
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 it empty if tools are available into your PATH).


Such hooks will work when using on command line but may also work when committing using your common IDE (it has been validated with Eclipse and VSC).  
Such hooks will work when using on command line but may also work when committing using your common IDE (it has been validated with Eclipse and VSC).  


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. If something is wrong in the syntax, the commit will be immediately canceled. If it can be fixed automatically, phpcbf will fix it so you just have to try the commit a second time to have it validated.
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. If something is wrong in the syntax, the commit will be immediately canceled. If it can be fixed automatically, phpcbf, installed during the install of the precommit hook, will fix it so you just have to try the commit a second time to have it validated.


=[[File:Computer.png]]  Optional=
=[[File:Computer.png]]  Optional=
There are a lot of more components you can install to get more technologies support:  
There are a lot of more components you can install to get more technologies support:  
[[Environment and development tools - Optionnal components]]
[[Environment and development tools - Optionnal components]]

Navigation menu