开发者

How can I add multiple SVN Hooks

I've got several (in this case, pre-commit) hooks that I would like to have run during the same event. Right now, t开发者_如何学运维hey are all just shell-scripts, so I know I could just concatenate them to get them all to run. In the future though, additional scripts may be written in Perl, PHP, or some other language as well.

How can I run several different scripts as part of a single hook, and have any one failure of the sub-hooks, fail as expected?


You can just invoke each script from the single pre-commit script in SVN:

#!/bin/sh

sh do_this.sh
php do_that.php
...

You don't even need to mention the executable names (sh or php) if you use a proper shebang in your scripts.


You can try the SVN::Hooks Perl module which lets you implement and integrate many hooks in a single configuration file, which can even be kept versioned in the same repository.

(Disclosure: I'm the author of that module.)


Much like @Gnustavo's Perl-based solution, I've also found some other (PHP-based) systems, such as

  • https://github.com/kore/php-commit-hooks
  • http://jeanmonod.github.com/php-svn-hook/

Both projects (and other 'SVN Hooks') will fail a commit if there's a failure of the tests.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜