RobbieGee
RobbieGee

Reputation: 1591

Can I run a script when I commit to subversion?

I'd like to run a script that builds the documentation for my php project. It is basically just using wget to run phpdoc.

Upvotes: 16

Views: 14754

Answers (4)

Aaron Maenpaa
Aaron Maenpaa

Reputation: 122890

An alternative to using SVN hooks would be to use a continuous integration engine. Personally, I'm a fan of Hudson. CruiseControl is the classic but there are a plethora of others.

Why use a continuous integration engine? In general, they're more powerful, feature rich and portable than simply using SVN hooks (what if you want to switch to using Mercurial, Git, etc. ?).

Upvotes: 3

Eran Galperin
Eran Galperin

Reputation: 86805

You might want to check out Phing for a complete build scripting tool. You can manage commits, documentation and other build related activities in one place.

Upvotes: 2

RobbieGee
RobbieGee

Reputation: 1591

(Answering my own question, I just thought others would like to know as well). Yes, and also TortoiseSVN supports it. The word you are looking for is 'hooks'.

For TortoiseSVN, open settings and 'Hook Scripts'. Click 'Add...' and chooe post_commit_hook (for running after the commit is done). Then add whatever script you are running and the working path of the script.

I used a batch file and called wget (there is a windows version ported, google it). To get wget to store the log from phpdoc in one specific path, you must specify the full path, else the log will be stored in the current folder from where you committed, so my batch file looks like this:

SET BUILDLOG=%~dp0%build_log.html
rem %~dp0 returns the full working path *of this script*
SET PHPDOCURL=http://localhost/PHPDocumentor/docbuilder
SET PHPDOCCONFIG=yourconfigfile

wget -O %BUILDLOG% "%PHPDOCURL%/builder.php?setting_useconfig=%PHPDOCCONFIG%&setting_output=HTML%3ASmarty%3Adefault&ConverterSetting=HTML%3ASmarty%3Adefault&setting_title=Generated+Documentation&setting_defaultpackagename=default&setting_defaultcategoryname=default&interface=web&dataform=true"

Now, whenever you commit, the batch script will be called. You could of course also use php as a command line tool, but I haven't looked into that with phpdoc - I just took the path of least resistance on this one.

Upvotes: 11

Oli
Oli

Reputation: 239810

Here's a fairly extensive tutorial on SVN hooks

Upvotes: 15

Related Questions