我是 SVN 的新手,正在努力学习它。我已经设置了 SVN 服务器,我可以签入/签出
来自它的文件。作为下一步,我正在尝试对其进行访问控制,并尝试添加一些提交挂钩
防止一些不需要的签到。
这是我的 svn 存储库:
/svnrepos/repo1
/svnrepos/repo2
/svnrepos/test >>>>>>> My test repository for playing around with SVN
现在我正在尝试使用预提交执行以下操作:
1. Preventing some users to check-in to a directory or any of its sub-folders
2. Preventing some files (say .class files) to be checked in by all users
这是我的环境:
Perl: v5.14.2 (linux 32-bit )
SVN: 1.7.4 (r1295709)
OS: Linux svnserver 2.6.18-164.el5 #1 SMP Tue Aug 18 15:51:54 EDT 2009 i686 i686 i386 GNU/Linux
我正在使用命令“svnserve -d -r /svnrepos --log-file /var/log/svn.log”运行 svn 服务器
现在我正在尝试为存储库/svnrepos/test 提供访问限制。我正在尝试编辑 commit-access-control.cfg 文件以提供访问限制。以下是此配置文件的内容:
[Make everything read-only for all users]
match = .*
access = read-only
[Make test project read-write for admin users ]
match = ^trunk/svnrepos/test/samplefile.txt
users = PR111319
access = read-write
以下匹配模式似乎不起作用:
match=^trunk/svnrepos/test/samplefile.txt
match=^/svnrepos/test/samplefile.txt
match=/svnrepos/test/samplefile.txt
match=/test/samplefile.txt
match=^/samplefile.txt
无论我给出什么匹配模式,在提交文件 samplefile.txt 时都会出现以下错误:
org.apache.subversion.javahl.ClientException: A repository hook failed
svn: Commit failed (details follow):
svn: Commit blocked by pre-commit hook (exit code 1) with output:
/svnrepos/test/hooks/commit-access-control.pl: user `PR111319' does not have permission to commit to
these paths:
/
samplefile.txt
但是,如果我将匹配项指定为 .* ,那么我就可以成功提交它。由此,我很清楚问题出在“匹配”上
以下是预提交文件的内容:
68 REPOS="$1"
69 TXN="$2"
70
71 # Make sure that the log message contains some text.
72 SVNLOOK=/opt/CollabNet_Subversion/bin/svnlook
73 $SVNLOOK log -t "$TXN" "$REPOS" | \
74 grep "[a-zA-Z0-9]" > /dev/null || exit 1
75
76 # Check that the author of this commit has the rights to perform
77 # the commit on the files and directories being modified.
78 /opt/ActivePerl-5.14/bin/perl "$REPOS/hooks/commit-access-control.pl" "$REPOS" "$TXN" "$REPOS/hooks/commit-access-control.cfg" || exit 1
79
80 # All checks passed, so allow the commit.
81 exit 0
如果您需要更多信息,请告诉我。
谢谢和问候, Parasuraman.R