Fork me on GitHub

php-svn-hook

Micro PHP framework to help you writting simple SVN hooks
by David Jeanmonod

Download

You can download this project in either zip or tar formats.

You can also clone the project with Git by running:

$ git clone git://github.com/jeanmonod/php-svn-hook

Installation

Usage

Initially the project is provide with two simple checks:

  1. Force adding a commit message
  2. Refuse tabulations in commit

If you ewant to do more, you will have to develop your own checks

Exemple

Let's try to commit a file with tabs:
[david]/Users/david/myProject/> svn commit -m "Add a file with tabs"
Sending        tab_file.php
Transmitting file data .svn: Commit failed (details follow):
svn: Commit blocked by pre-commit hook (exit code 1) with output:

PRE COMMIT HOOK FAIL:
The following pre commit check fail:
 * Reject tabulation in files: 1 tabs found

DETAIL OF THE CHECKS ERRORS:
Reject tabulation in files:
trunk/tab_file.php:21 Char 16 is a tab

If you want to force commit tabs, add the parameter --allow-tabs in your comment

Create your own checks

You will probably want to create your own checks, that's easy!

Testing

As it's can be panful to process a commit each time you want to test your scripts, there is test suite avaliable based on lime (extracted from symfony 1.4).

Just go to the root folder and run:

php test/run_all.php

To run a specific check test, call directly the test file, for exemple:

php test/checks/NoTabCheckTest.php

To write your own test, just copy and paste and existing test file, and adapt it!

How to contribute

If you want to contribute please fell to fork or to send your comment. I will be happy to complete this repo according to your needs...