我是SVN的新手,試圖學習它。我已經設置了SVN服務器,並且我可以通過它登記/登出SVN:Commit-access-control.cfg問題
文件。 作爲下一步,我試圖對其進行訪問控制,並試圖添加一些提交掛鉤到
防止一些不需要的檢入。
這裏是我的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服務器「
現在我試圖提供對repository/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
不管匹配模式我給,我收到以下錯誤,而commiting文件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
您似乎對SVN存儲庫的組織方式感到非常困惑。我甚至不知道從哪裏開始。 'repo1','repo2'和'test'全部由服務器單獨提供。每個存儲庫對「svnrepos」目錄一無所知(它只指定服務器的位置以知道存儲庫的位置)。所以包含'svnrepos'的任何'match'都是無意義的。 「表達式」trunk \ svnrepos ...' - 你從哪裏得到那個'trunk'?我認爲你需要[進一步閱讀](http://svnbook.red-bean.com/en/1.7/svn-book.html)。 –
@malenkiy_scot感謝您的回覆。 「commit-access-control.cfg」文件包含一個示例部分,其中顯示了以下內容:[[但是,我們不信任Joe和project1的Makefile] match = ^(branches | trunk |/project1/Makefile users = joe access = read-only'這就是我得到'trunk'這個詞的地方。 我使用命令'svnadmin create test'創建了存儲庫。之後,我嘗試使用subclipse SVN插件在我的eclipse中打開它。從日食我連接到該存儲庫使用svn:// /test.added samplefile.txt並簽入相同。 –
Parasu
因此,該文件位於存儲庫「測試」中。因此,我試着像'^/test/samplefile.txt,^/samplefile.txt,/test/samplefile.txt,^ trunk/test/samplefile.txt',但都得到相同的錯誤。我目前正在通過文檔。希望我會學習基礎知識:) – Parasu