Tuesday, April 30, 2013

How to force comments on Subversion Commit with Perl hook script

Today i got a requirement from one of our senior developer to force a comments on svn commit.
We are using Subversion in linux.

We have to create a file pre-commit under /{repository-location}/hooks/

cd /{repository-location}/hooks/
touch pre-commit
chmod 775 pre-commit

Copy paste the following code in pre-commit file.


# config section
$minchars = 4;
$svnlook = '/usr/bin/svnlook';

$repos = $ARGV[0];
$txn = $ARGV[1];
$comment = `$svnlook log -t "$txn" "$repos"`;

if ( length($comment) == 0 ) {
  print STDERR "A comment is required!";
elsif ( length($comment) < $minchars ) {
  print STDERR "Comment must be at least $minchars characters.";


No comments:

Post a Comment