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.
#!/usr/bin/perl
# config section
$minchars = 4;
$svnlook = '/usr/bin/svnlook';
#--------------------------------------------
$repos = $ARGV[0];
$txn = $ARGV[1];
$comment = `$svnlook log -t "$txn" "$repos"`;
chomp($comment);
if ( length($comment) == 0 ) {
print STDERR "A comment is required!";
exit(1);
}
elsif ( length($comment) < $minchars ) {
print STDERR "Comment must be at least $minchars characters.";
exit(1);
}
exit(0);
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.
#!/usr/bin/perl
# config section
$minchars = 4;
$svnlook = '/usr/bin/svnlook';
#--------------------------------------------
$repos = $ARGV[0];
$txn = $ARGV[1];
$comment = `$svnlook log -t "$txn" "$repos"`;
chomp($comment);
if ( length($comment) == 0 ) {
print STDERR "A comment is required!";
exit(1);
}
elsif ( length($comment) < $minchars ) {
print STDERR "Comment must be at least $minchars characters.";
exit(1);
}
exit(0);