1

我正在尝试测试一些 Subversion 提交挂钩,但是当我使用最简单的情况时 - 本地存储库和 file:// 协议 - 然后挂钩不会执行。

我在 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.

由于我的极端提交钩子,那里的最后一个命令应该失败。我究竟做错了什么?

4

2 回答 2

1

原来是我的错误 - 在批处理文件中,“exit 1”向 svn 返回错误,而“exit /b 1”没有。

于 2011-02-08T18:02:29.060 回答
0

这是一个愚蠢的答案,但是您是否验证了预提交挂钩的权限?它在任何其他条件下都有效吗?

您可能对文件 URL 没有问题,一般来说您可能对钩子有问题。

于 2011-02-08T15:39:00.337 回答