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.
If you want to manually run all pre-commit hooks on a repository, run pre-commit run --all-files . To run individual hooks use pre-commit run <hook_id> . The first time pre-commit runs on a file it will automatically download, install, and run the hook. Note that running a hook for the first time may be slow.
The pre-commit hook is run first, before you even type in a commit message. It's used to inspect the snapshot that's about to be committed, to see if you've forgotten something, to make sure tests run, or to examine whatever you need to inspect in the code.
A hook script is a program triggered by some repository event, such as the creation of a new revision or the modification of an unversioned property. Each hook is handed enough information to tell what that event is, what target(s) it's operating on, and the username of the person who triggered the event.
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
You cannot. The script needs to check all the affected paths (they can be more than one) and act accordingly.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With