简体   繁体   English

SVN Edge的预提交挂钩上的错误

[英]Errors on the Pre-commit hook of SVN Edge

Good day! 美好的一天! I am currently working on existing SVN Edge and TortoiseSVN of my company. 我目前正在研究公司现有的SVN Edge和TortoiseSVN。 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: 首先,我将“ pre-commit.tmpl”重命名为“ pre-commit”,然后将代码修改为以下内容,但我不断收到以下错误:

Error1:"/usr/bin/svnlook: not found" (ie the value of SVNLOOK) 错误1:“ / usr / bin / svnlook:未找到”(即SVNLOOK的值)

Error2:"If you want to break the lock, use the 'Check For Modifications' dialog or the repository browser." 错误2:“如果您想解除锁定,请使用“检查修改”对话框或存储库浏览器。”

What should be the value of SVNLOOK? 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): 第一次尝试(SVN Edge原始):

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 ): 第二次尝试( 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/ ): 第三次尝试( 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);

Error 1: 错误1:
Yes, svnlook is a file. 是的, svnlook是一个文件。 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). 任何bash程序都是一个文件,位于$PATH的目录之一内(很抱歉,如果您听起来已经很多余了,那听起来就很多余了)。
Most essential 'system scripts' are found in /bin , and application scripts are found in /usr/bin . 最基本的“系统脚本”位于/bin ,而应用程序脚本位于/usr/bin
That means that if your svnlook is installed in a different directory, you might need to look for it. 这意味着,如果您的svnlook安装在其他目录中,则可能需要查找它。
If you are running Windows, you will need to provide the path to the executable file. 如果您正在运行Windows,则需要提供可执行文件的路径。
Error 2: 错误2:
This might help you. 可能对您有帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM