【问题标题】:Set up svnperms pre-commit hook设置 svnperms 预提交钩子
【发布时间】:2010-10-29 08:11:14
【问题描述】:

我正在尝试将 svnperms 实现到存储库中,但在一些事情上遇到了困难:

pre-commit 具有执行权限:

-rwxrwxr-x   1 svnadm     svn           3018 May 27 10:11 pre-commit

这是我在预提交中对 svnperms 的调用:

# Check that the author of this commit has the rights to perform
# the commit on the files and directories being modified.
SVNPERMS=/usr/local/svn/scripts/svnperms.py
$SVNPERMS -r $REPOS -t $TXN || exit 1

我已经在指定位置安装了 svnperms.py:

# ls -l /usr/local/svn/scripts
total 24
-rwxrwxr-x   1 svnadm     svn          11840 May 25 07:48 svnperms.py

svnperms.py 是 UNIX 格式 - 没有 ^M 行结尾。

TortoiseSVN 回来了:

Command: Commit  
Modified: C:\projects\Sandbox\Trunk\Test.txt  
Sending content: C:\projects\Sandbox\Trunk\Test.txt  
Error: Commit failed (details follow):  
Error: 'pre-commit' hook failed with error output:  
Error: No such file or directory: python  

不带参数调用 svnperms 显示:

/usr/local/svn/scripts/svnperms.py
missing required option(s): repository, either transaction or a revision
Usage: svnperms.py OPTIONS

Options:
    -r PATH    Use repository at PATH to check transactions
    -t TXN     Query transaction TXN for commit information
    -f PATH    Use PATH as configuration file (default is repository
               path + /conf/svnperms.conf)
    -s NAME    Use section NAME as permission section (default is
               repository name, extracted from repository path)
    -R REV     Query revision REV for commit information (for tests)
    -A AUTHOR  Check commit as if AUTHOR had commited it (for tests)
    -h         Show this message

UNIX 管理员最近安装了 python,但不确定是否所有依赖项都在那里。如果这是问题所在,我不确定如何确定,因为 python 似乎根据上面的输出工作。

我错过了什么?

【问题讨论】:

    标签: python svn unix pre-commit


    【解决方案1】:

    我的猜测是 python 二进制文件的位置不在 svn 服务器的 $PATH 中。 svnperms.py的沙帮行写着:

    #!/usr/bin/env python
    

    但这假设可执行文件位于调用者的$PATH 中。如果您没有权限修改您的 subversion 服务器的运行时环境,请尝试在交互运行时将 shabang 行中的python 替换为which python 给出的路径。

    【讨论】:

    • 谢谢!做到了!再看注释,显然脚本不继承 $PATH 是一个常见问题。
    • 根据svnbook.red-bean.com/en/1.5/…,出于安全目的,程序在空环境中执行。
    猜你喜欢
    • 2019-07-12
    • 2013-03-20
    • 2013-12-15
    • 2017-02-08
    • 2016-09-02
    • 1970-01-01
    • 2013-05-13
    • 2022-01-07
    相关资源
    最近更新 更多