我在Windows 2008 R2服务器计算机上安装了Bonobo Git服务器。我创建了一个存储库,并将post-receive.bat
文件放在D:InetpubBonobo.Git.ServerApp_DataRepositoriesREPOhooks
目录中。
这是文件的内容:
#!/D/Inetpub/Bonobo.Git.Server/App_Data/Git/sh.exe
BINPATH="/D/Inetpub/Bonobo.Git.Server/App_Data/Git/"
REPOPATH="/D/Inetpub/Bonobo.Git.Server/App_Data/Repositories/REPO/"
GIT="${BINPATH}git"
# Change working directory to the repo root
cd $REPOPATH
read oldrev
read newrev
read refname
branch=$($GIT rev-parse --symbolic --abbrev-ref $refname)
if [ "master" == "$branch" ]; then
echo "receive $branch $refname" >> "${REPOPATH}hookstest.log"
fi
如果我从shell执行此文件并键入"任何主机",则将文件"接收主"添加到hookstest.log
中。但是,当我推动更改以回购文件时,该文件未更新,就像没有执行一样。
我不知道在哪里寻找发生的错误。大多数Linux教程都提到该文件必须具有 x标志。这显然在Windows上不存在,但是我检查了IIS中运行Bonobo Git服务器的用户在批处理文件上具有执行权。
我也对文件的名称犹豫不决,因此我将其复制并删除。那也没有帮助。知道如何使挂钩在Windows Server上工作?
编辑
@crashmstr建议我创建了一个批处理文件(一个带有扩展名,一个没有(,其中包含:
date /t >> D:InetpubBonobo.Git.ServerApp_DataRepositoriesREPOtesthooks.txt
当我手动执行文件时,即使创建了文件。
使用最新版本的bonobo(比6.1晚,但该区域中没有任何更改(,我刚刚创建了一个名为'Pre-Receive'的文件,仓库
此文件在文件名上没有扩展名,仅包含以下内容:
#!/bin/sh
echo "xx" > here.txt
当我将提交推向此仓库时,文件" there.txt"写入了repo文件夹的顶部。
如果此 这些文件没有被编写/读取。
观看" there.txt"用procmon编写,表明它是由 App_DataGitsh.exe
中的sh.exe副本编写的。我不太确定从'#!/bin/sh'到 App_DataGitsh.exe
的是谁,但它似乎有效。
我不确定问题所在。最后,我通过创建一个文件D:InetpubBonobo.Git.ServerApp_DataRepositoriesREPOhookspost-receive
(无扩展(的内容来使它起作用:
#!/D/Inetpub/Bonobo.Git.Server/App_Data/Git/sh.exe
echo "BEGIN post-receive script"
APPPATH="/D/Inetpub/Bonobo.Git.Server/App_Data"
SVN="/D/csvn/bin/svn"
REPOPATH="$APPPATH/Repositories/REPO"
SVNSYNCPATH="$APPPATH/SVN-sync"
GIT="$APPPATH/Git/git"
mapping["master"]="trunk"
mapping["develop"]="development"
# Change working directory to the repo root
cd $REPOPATH
read oldrev newrev refname
echo "oldrev - $oldrev"
echo "newrev - $newrev"
echo "refname - $refname"
branch=$($GIT rev-parse --symbolic --abbrev-ref $refname)
echo "branch - $branch"
echo ""
if [ "master" == "$branch" ]; then
result=($($GIT diff $oldrev $newrev --name-status))
echo "Detected $((${#result[@]}/2)) changes:"
idx=0
while [ $idx -lt ${#result[@]} ]
do
status=${result[$idx]}
filename=${result[$(($idx+1))]}
echo -n "$status - $filename "
case $status in
"A")
echo "added"
;;
"M")
echo "updated"
;;
"D")
echo "deleted"
;;
"R")
echo "renamed"
;;
"C")
echo "copied"
;;
*)
echo "unknown status"
;;
esac
idx=$(($idx+2))
done
fi
echo ""
echo "END post-receive script"