Recipe: SVN post-commit hooks in Perl
As the original SVN documentation about post-commit hooks has obviously been written by Trappist monks (larsbot, did you know they also have a special beer?) and the googlian brute force gives me cranky
64,200 useless results for SVN post-commit hooks
I spent some trial&error time for installing an SVN hook which is supposed to be triggered whenever a document is committed into the SVN repository.
Activating a hook itself is trivial: you just create in the directory
an executable file named post-commit, in my case a Perl script:
The real problem is how does that know about the file name involved, or the content therein? That can be achieved with svnlook:
my $file = $1;
Note that you always have to use full path names for executables to be found. If you need the contents itself, then
Sidenote: In pre-commit you do not get the committed revision but a transaction number you can follow up as well:
my $path = shift @ARGV;
my $txn = shift @ARGV;
`/usr/bin/svnlook changed -t $txn $path` =~ /U\s+(.*)$/;
Feeding the cranky kid.