Pre-commit hook for running checkstyle [GIT]
Open working git repository and find .git directory.
Create directory with name hooks if it does not exist.
- pre-commit - script, hook it self
- checkstyle-all-4.3.jar - checkstyle library for running
- checkstyle.xml - your own checkstyle configuration regarding policies (I used spring checkstyle configuration here just to show what is need)
Copy them in hooks folder.
Next step is update repository git configuration file.
Find and open file in .git with name config.
Add at the bottom lines:
[checkstyle] jar = c:/my_project/.git/hooks/checkstyle-all-4.3.jar checkfile = c:/my_project/.git/hooks/dlex_checks.xml
Do not forget to update paths to jar and checkstyle file which you are copied and save config file.
That’s it. Nothing need to be reloaded…