2011-02-08 60 views
1

我想測試一些Subversion提交掛鉤,但是當我使用最簡單的情況 - 本地存儲庫和file://協議 - 然後掛鉤不會執行。Subversion掛鉤是否可以使用文件URL?

我在Windows上 - 這裏有一個簡單的例子的成績單:

C:\>mkdir \testsvn  
C:\>mkdir \testsvn\repos  
C:\>cd \testsvn\repos  
C:\testsvn\repos>svnadmin create --fs-type fsfs /testsvn/repos  
C:\testsvn\repos>cd \testsvn  
C:\testsvn>mkdir source  
C:\testsvn>cd source  
C:\testsvn\source>echo This is a readme file.>readme.txt  
C:\testsvn\source>svn import file:///testsvn/repos/somemodule -m "Imported somemodule" 
Adding   readme.txt  
Committed revision 1. 

C:\testsvn\source>cd \testsvn\repos\hooks  
C:\testsvn\repos\hooks>copy con pre-commit.bat 
echo Commits disabled! 1>&2 
exit /b 1 
^Z 
     1 file(s) copied. 

C:\testsvn\repos\hooks>md \testsvn\checkout  
C:\testsvn\repos\hooks>cd \testsvn\checkout  
C:\testsvn\checkout>svn checkout file:///testsvn/repos/somemodule 
A somemodule\readme.txt 
Checked out revision 1. 

C:\testsvn\checkout>cd somemodule  
C:\testsvn\checkout\somemodule>echo This is line 2 of the readme file.>>readme.txt  
C:\testsvn\checkout\somemodule>svn status -u 
M    1 readme.txt 
Status against revision:  1 

C:\testsvn\checkout\somemodule>svn commit -m "This should fail if the pre-commit hook works..." 
Sending  readme.txt 
Transmitting file data . 
Committed revision 2. 

最後的命令應該是因爲我極度的失敗commit鉤子。我究竟做錯了什麼?

回答

1

原來是我的錯誤 - 在批處理文件中,「exit 1」向svn返回錯誤,而「exit/b 1」不會。

0

這是一個愚蠢的答案,但你是否驗證了預提交鉤子的權限?它在其他條件下工作嗎?

你可能沒有文件URL的問題,你可能在鉤子方面有問題。

+0

我可以運行批處理文件,pre-commit.bat,它做我所期望的(在這種簡化的情況下,寫一條錯誤消息並返回一個錯誤代碼)。 – Jonathan 2011-02-08 17:11:20

相關問題