8

One of our client's SVN repository has quite a bunch of projects under the single repository. Now I want to check coding-standard for one of the project via pre-commit hook.

If I configure the pre-commit, it is going to affect all the projects (folders) in the repository, how do I tell the hook-script to trigger (check the coding standard) only when a file from a particular folder (or project) is committed.

UPDATE

The coding standard is intentional for Zend and I am going to use PHPCS (PHP Coding Standard) to validate the coding-standard.

hakre
  • 193,403
  • 52
  • 435
  • 836
Rakesh Sankar
  • 9,337
  • 4
  • 41
  • 66

2 Answers2

7

Use svnlook in the pre-commit to see the paths changed, and if the path contains the project you are considering, do the coding standards etc.

You can use the dirs-changed subcommand (and the --transaction flag):

http://svnbook.red-bean.com/en/1.5/svn.ref.svnlook.c.dirs-changed.html

Or the changed subcommand:

http://svnbook.red-bean.com/en/1.5/svn.ref.svnlook.c.changed.html

Example of a pre-commit using svnlook: http://wordaligned.org/articles/a-subversion-pre-commit-hook

manojlds
  • 290,304
  • 63
  • 469
  • 417
1

You cannot. The script needs to check all the affected paths (they can be more than one) and act accordingly.

Álvaro González
  • 142,137
  • 41
  • 261
  • 360
  • @Alvaro-g-vicario don't say that, there should be some way. – Rakesh Sankar Aug 16 '11 at 06:55
  • @RakeshS - Of course there is: make your script check all the affected paths and act accordingly. See manojlds' answer for the exact details. – Álvaro González Aug 16 '11 at 07:01
  • @RudolfMayer Not sure why someone who knows that two answers to a given question are wrong would leave a complaint comment in the non-accepted one rather sharing his knowledge in a proper answer. Meanwhile, I reassert my statement (you cannot configure Subversion to trigger hooks based on paths, you have to write a hook that runs *every time* and implements its own path filter logic) and I address to manojlds' excellent answer for some good hints on how to do it. – Álvaro González Aug 06 '15 at 09:02