Git 哪个用户在Windows计算机上执行post接收钩子?

Git 哪个用户在Windows计算机上执行post接收钩子?,git,windows-7,githooks,Git,Windows 7,Githooks,因此,我在我的裸回购中有一个post receivehook,它将在我的trac安装中更新票据(hook取自) git repo位于驱动器G:上,而trac数据库存储在F:\user\trac\myproject上。我定制了原始挂钩,以便路径正确: TRAC_ENV = 'F:\\User\\Trac\\myproject' GIT_PATH = "C:\\Program Files (x86)\\Git\\bin\\git.exe" 在将钩子上传到服务器之前,我在本地机器上验证了正确的语法(

因此,我在我的裸回购中有一个
post receive
hook,它将在我的trac安装中更新票据(hook取自)

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'
remote:Traceback(最近一次呼叫最后一次):
远程:文件“hooks/post receive”,第190行,在
远程:env=开放式环境(TRAC\u env)
远程:文件“build\bdist.win-amd64\egg\trac\env.py”,第846行,在OpenU环境中
远程:文件“build\bdist.win-amd64\egg\trac\core.py”,第124行,在调用中__
远程:文件“build\bdist.win-amd64\egg\trac\env.py”,第283行,在__
远程:验证中第392行的文件“build\bdist.win-amd64\egg\trac\env.py”
远程:trac.core.TracError:在f:\user\trac\myproject中找不到trac环境
远程:[Errno 2]没有这样的文件或目录:“f:\\user\\trac\\myproject\\VERSION”
所以我猜这是一个访问权限相关的问题,执行
post-receive
hook的用户没有访问trac目录的权限


为了克服此问题:我需要哪个用户授予对trac数据库的访问权限,以便成功执行挂钩?要直接回答您的问题,您可以添加

import getpass
print >> sys.stderr, getpass.getuser()
就在钩子的import语句之后,当您尝试推送时,它应该在错误之前输出用户名


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

只是路过。你在TRAC_ENV中有单引号是正确的吗?@bahrep:yep。在我的本地Windows 7计算机上工作正常。你确定
f:\user\trac\myproject\VERSION
存在吗?此
版本
看起来像是未分配环境变量的问题。您是否100%确定软件没有尝试访问
f:\\user\\trac\\myproject\\VERSION
(即使用双斜杠)?Windows不会将重复的路径分隔符压缩为一个,因此
C:\\Windows
不是有效的路径。