2016-03-11 114 views
0

美好的一天!我目前正在研究我公司的现有SVN Edge和TortoiseSVN。我们从来没有使用预先提交的钩子,并且在读完所有的Q后,我决定放置提交消息的需求。 首先,我将'pre-commit.tmpl'重命名为'pre-commit',然后将代码修改为以下内容,但我不断收到以下错误:SVN Edge预挂钩错误

Error1:“/ usr/bin/svnlook:not找到“(即SVNLOOK的值)

错误2:”如果您想中断锁定,请使用'检查修改'对话框或存储库浏览器。“

SVNLOOK的价值应该是什么?或者我需要修改哪一行。 请帮我看看我错过了什么......我真的很困惑,我不是开发者。 非常感谢!

第一尝试(SVN边缘原始):

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 

第二尝试(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); 

第三尝试(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); 
+0

我不知道你的svnlook可能在哪里......你可以尝试'find/usr | grep“svnlook”'找到路径。 – Majora320

+0

SVNLOOK是一个文件?那么,我需要找到它的位置在哪里?......谢谢Majora! – nova

回答

1

错误1:
是的,svnlook是一个文件。任何bash程序都是一个文件,在您的$PATH中的其中一个目录中找到(对不起,如果这听起来太可怕了,因为你已经知道了)。
在“/bin”中找到最基本的“系统脚本”,在/usr/bin中找到应用程序脚本。
这意味着如果您的svnlook安装在不同的目录中,则可能需要查找它。
如果您正在运行Windows,则需要提供可执行文件的路径。
错误2:
This可能会帮助你。

+1

好极了,根本不需要保证,因为我需要非常基本的信息。肯定会回到你的结果。 – nova

+1

回到Error2,我的工作拷贝文件都没有被锁定。 – nova

+1

对于Error1,我在本地发现了svnlook.exe。我正在查看正确的文件吗?或者它应该是一个服务器文件? – nova