I found the install instructions a bit too terse. It assumes a lot that goes unmentioned.
This may not be what is intended, but it's the process I guessed at to get this working. There are other ways, I'm sure, this was the single straight line I followed on a dev machine to try this module out...
Starting from a (Ubuntu) server that already had drush installed,
For a platform-wide install (We don't add external devel review modules to projects themselves, this should be a re-usable toolset)
- This module requires 'coder' to be available with its drush drupalcs command
-
First download both these whole modules as a system-wide drush libraries
cd /usr/share/drush/commands/ drush dl coder dcq drush cc drush drush help drupalcs
-
Test drupalcs has its requirements.
Choose a module or project that is currently checked out with git.cd $path_to/$some_crappy_module drush drupalcs ${some_crappy_module}.module # No compatible version of PHP_CodeSniffer was found;
-
I didn't have that yet, so need to sort that out as the instructions say.
sudo pear update-channels sudo pear install PHP_CodeSniffer sudo ln -sv /usr/share/drush/commands/coder/coder_sniffer/Drupal $(pear config-get php_dir)/PHP/CodeSniffer/Standards/Drupal drush drupalcs ${some_crappy_module}.module
.. and that's now working!
-
Now we can move on with the git hook thing. There are two options (or maybe three) options for this. The first is on a per Git project basis.
I'll actually LINK the pre-commit stuff.. From the root of the project where .git is.ln -s /usr/share/drush/commands/dcq/pre-commit .git/hooks/ ln -s /usr/share/drush/commands/dcq/pre-commit_dcq .git/hooks/ chmod a+x .git/hooks/pre-commit chmod a+x .git/hooks/pre-commit_dcq
- Edit module to do some sloppy code ...
- git commit -m "I'm a lazy coder" .
And it all works!
Precommit
Checking file back_to_top.module
PHP_CodeSniffer found at least one issue. [error]
FILE: /home/sparks/test-dcq/back_to_top.module
--------------------------------------------------------------------------------
FOUND 6 ERROR(S) AFFECTING 5 LINE(S)
--------------------------------------------------------------------------------
3 | ERROR | The second line in the file doc comment must be " * @file"
4 | ERROR | The third line in the file doc comment must contain a description
| | and must not be indented
6 | ERROR | Missing function doc comment
7 | ERROR | Line indented incorrectly; expected 2 spaces, found 1
7 | ERROR | Blank comments are not allowed
9 | ERROR | Files must end in a single new line character
--------------------------------------------------------------------------------
The other option is to install the pre-commit hooks more globally on the machine. This can effect just the current user using gitconfig. As of git 1.7.1, you can set init.templatedir in your gitconfig to tell git where to look for templates.
git config --global init.templatedir '~/.git_template'
Or you can effect the entire machine by adding the hooks to the following location where $PREFIX commonly is /usr or /usr/local.
$PREFIX/share/git-core/templates/hooks
... Now to go and inflict this on my team :-B
Comments
Comment #1
eugene.ilyin CreditAttribution: eugene.ilyin commentedThank you! I added link to this issue on main page of project.
Comment #3
heddn