SVN预提交挂钩中的用户验证
在我想在提交之前在用户上添加验证检查.我可以做下面的事情吗?
I want to add the validation check on the user before committing. Can I do something like below?
@echo off
REM user1, user2, user3 are example
set VALID_USERS=user1,user2,user3
set SVNROOT="C:\Program Files\CollabNet Subversion Server\svnlook.exe"
set REPOS=%1%
set TXN=%2%
%SVNROOT% author %REPOS% -t %TXN% | findstr /r "^%VALID_USERS%$" >nul
if %errorlevel% EQU 0 (
echo This is an invalid user 1>&2
exit 1
) else (
echo This is valid user 1>&2
exit 0
)
由于所有用户都可以提交其文件,因此上述预提交脚本失败.另外,'echo'命令不起作用,因为我在上面看不到任何echo语句.有人可以帮忙吗?
The above pre-commit script failed as all users can commit their files. Also, the 'echo' command not working as I don't see any echo statement above. Can anyone help?
我不明白您为什么要为此使用一个预提交钩子,所以我给您一个草图,供我们在处理标签时使用.
I don't understand why you should want a pre-commit hook for that, so I give you a sketch what we are using when working on tags.
-
我们使用Subversion 路径的授权,并且具有类似的规则:
We use the Subversion path-based authorization, and have rules like that:
[/tags]
* = r
@R_SVN_ADMINS = rw
所以只有管理员才能创建和修改标签.
so only admins are allowed to create and modify tags.
如有必要,我们为每个标签添加一条规则以避免修改:
If necessary, we add for each tag a rule to avoid modification:
[/tags/r1.0]
@R_SVN_ADMINS = r
这对我们有用,因为很少创建标签,而且我们没有太多标签.我们不需要任何钩子就可以禁止某物...
This works for us because tags are created seldomly, and we don't have much of them. We don't need any hooks to forbid something ...