SVN预提交挂钩中的用户验证 [英] Users validation in SVN pre-commit hook

查看:175
本文介绍了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.

  1. 我们使用Subversion 路径的授权,并且具有类似的规则:

  1. 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 ...

    这篇关于SVN预提交挂钩中的用户验证的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

    查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆