svntortoisesvncollabnet

Errors on the Pre-commit hook of SVN Edge


Good day! I am currently working on existing SVN Edge and TortoiseSVN of my company. We never make use of pre-commit hook and upon reading all the Q&A here I decided to put put in place the requirement for a commit message. First, I renamed 'pre-commit.tmpl' to 'pre-commit' then modified the code to the following but I'm constantly receiving the below errors:

Error1:"/usr/bin/svnlook: not found" (i.e. the value of SVNLOOK)

Error2:"If you want to break the lock, use the 'Check For Modifications' dialog or the repository browser."

What should be the value of SVNLOOK? Or which line do I need to modify. Please help me what I am missing... I am really confused and I'm not a developer. Many thanks!!!

1st attempt (SVN Edge original):

REPOS="$1"
TXN="$2"

# Make sure that the log message contains some text.
SVNLOOK=/opt/CollabNet_Subversion/bin/svnlook
$SVNLOOK log -t "$TXN" "$REPOS" | \
   grep "[a-zA-Z0-9]" > /dev/null || exit 1

# Check that the author of this commit has the rights to perform
# the commit on the files and directories being modified.
commit-access-control.pl "$REPOS" "$TXN" commit-access-control.cfg || exit 1

# All checks passed, so allow the commit.
exit 0

2nd attempt (http://www.wandisco.com/svnforum/forum/opensource-subversion-forums/scripts-contributions/9015-pre-commit-comment-hook-script):

#!/usr/bin/perl

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

#--------------------------------------------
$repos = $ARGV[0];
$txn = $ARGV[1];
$comment = `$svnlook log -t "$txn" "$repos" | grep "[A-Z][A-Z][A-Z]-*"`;
chomp($comment);

if ( length($comment) == 0 ) {
print STDERR "Your commit has been blocked as you did not input a Product reference id. Please input an id in the form of ABC-123!";
exit(1);
}
elsif ( length($comment) < $minchars ) {
print STDERR "Comment must be at least $minchars characters.";
exit(1);
}

exit(0);

3rd attempt (http://www.stillnetstudios.com/require-subversion-comments-minimum/):

#!/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);

Solution

  • Error 1:
    Yes, svnlook is a file. Any bash program is a file, found within one of the directories in your $PATH (Sorry if that sounded horribly redundant because you knew that already).
    Most essential 'system scripts' are found in /bin, and application scripts are found in /usr/bin.
    That means that if your svnlook is installed in a different directory, you might need to look for it.
    If you are running Windows, you will need to provide the path to the executable file.
    Error 2:
    This might help you.