哪个用户在Windows机器上执行post-receive挂钩?

时间:2013-11-18 12:38:31

标签: git windows-7 githooks

所以我的裸仓库中有post-receive钩子,它将在我的trac安装中更新门票(钩子取自http://trac.edgewall.org/attachment/wiki/TracGit/post-receive-hook.py)。

git repo位于驱动器G:上,而trac数据库存储在F:\user\trac\myproject上。我定制了原始钩子,以便路径正确:

TRAC_ENV = 'F:\\User\\Trac\\myproject'
GIT_PATH = "C:\\Program Files (x86)\\Git\\bin\\git.exe"

在我将钩子上传到我的服务器之前,我在本地机器上验证了正确的语法(反斜杠等),其中一切正常。

现在,我将钩子上传到G:\git\myproject.git\hooks\post-receive并推送一些引用。但这给了我一个错误信息:

remote: Traceback (most recent call last):
remote:   File "hooks/post-receive", line 190, in <module>
remote:     env = open_environment(TRAC_ENV)
remote:   File "build\bdist.win-amd64\egg\trac\env.py", line 846, in open_environment
remote:   File "build\bdist.win-amd64\egg\trac\core.py", line 124, in __call__
remote:   File "build\bdist.win-amd64\egg\trac\env.py", line 283, in __init__
remote:   File "build\bdist.win-amd64\egg\trac\env.py", line 392, in verify
remote: trac.core.TracError: No Trac environment found at f:\user\trac\myproject
remote: [Errno 2] No such file or directory: 'f:\\user\\trac\\myproject\\VERSION'

所以我猜这是一个与访问权限相关的问题,执行post-receive钩子的用户无法访问trac目录。

为了克服这个问题:我需要哪个用户访问trac数据库才能成功执行挂钩?

1 个答案:

答案 0 :(得分:0)

要直接回答您的问题,您可以添加

import getpass
print >> sys.stderr, getpass.getuser()

在钩子的import语句之后,当你试图推送时它应该在错误之前输出用户名。

然而,它给出错误“没有这样的文件或目录”这可能意味着它,它试图访问不存在的文件。因此,这不会是权限问题,并且可能意味着trac未在该位置正确安装或者trac模块存在问题。

相关问题