我一整天都在用谷歌搜索这些东西,虽然我得到了大量的结果,但似乎没有什么能帮助我解决这个问题。
我已经在我的远程Apache服务器上安装了SVN。我设置了我的存储库,并添加了所有的代码文件。没问题。我在本地的windows机器上安装了TortoiseSVN,可以毫无问题地签出和提交文件。我还签出了远程服务器上的文件,因为该项目是一个网站。我想做一个post commit钩子,这样每次提交时,远程服务器的工作目录都会进行更新。我在hooks目录中创建了post- copy .tmpl的副本,并为所有用户设置了可执行标志。我的问题是,每次我通过TortoiseSVN进行提交时,我都会得到以下错误:
post-commit hook failed with error output:暂时不要管post-commit的实际内容--它根本不会执行。我一直在阅读所有这些关于用户、组、权限等的帖子,我似乎就是看不到大局。很多人提到post-commit必须属于运行apache的同一用户,或者类似的用户。我需要细节!如果是真的,我该如何找出哪个用户和组正在运行Apache?这就是故事的结尾吗?我用来通过TortoiseSVN提交到SVN的凭据呢?它们重要吗?重要的是提交后的权限和用户,还是整个svn安装?
我尝试将整个svn工作目录的所有者(钩子和所有)设置为我能想到的每种组合(apache.apache、root.root、root.psaserv、apache.root),等等。目前,我使用root/rootpassword作为我的Tortoise凭证。
以下是我的钩子目录的内容:
-rwxr-xr-x 1 apache apache 2061 Feb 2 18:04 post-commit
-rw-r--r-- 1 apache apache 2015 Feb 2 07:44 post-commit.tmpl
-rw-r--r-- 1 apache apache 1638 Feb 2 07:44 post-lock.tmpl
-rw-r--r-- 1 apache apache 2255 Feb 2 07:44 post-revprop-change.tmpl
-rw-r--r-- 1 apache apache 1567 Feb 2 07:44 post-unlock.tmpl
-rw-r--r-- 1 apache apache 2934 Feb 2 07:44 pre-commit.tmpl
-rw-r--r-- 1 apache apache 2038 Feb 2 07:44 pre-lock.tmpl
-rw-r--r-- 1 apache apache 2764 Feb 2 07:44 pre-revprop-change.tmpl
-rw-r--r-- 1 apache apache 1979 Feb 2 07:44 pre-unlock.tmpl
-rwxrwxrwx 1 apache apache 0 Feb 2 19:48 sanity.txt
-rw-r--r-- 1 apache apache 2137 Feb 2 07:44 start-commit.tmpl
-rwsr-sr-x 1 root root 4802 Feb 2 14:32 svnupdate
-rw-r--r-- 1 apache apache 212 Feb 2 14:32 svnupdate.c我无计可施了,伙计们。请帮助一个可怜的Linux新手!
发布于 2010-02-03 23:23:48
如果您按如下方式运行它,可能会更好地诊断它:
$ unset PATH
$ <your_svn_repo>/hook/post-commit <your_svn_repo> <some_revision_number>SVN的提交钩子在一个非常受限的环境中运行,执行路径上没有任何东西,因此您必须确保您编写的每个脚本也可以以这种方式运行。
根据你的评论,我认为你的文件的第一行是Windows行结尾,而不是unix行结尾。您可能是在记事本或其他Windows编辑器中编辑了该文件,这些编辑器在行结束方面不是很智能。
让它正常工作的最快方法可能是在命令提示符下(假设您运行的是Linux或安装了dos2unix的系统):
dos2unix /var/www/vhosts/example.com/svn/hooks/post-commit如果没有dos2unix命令,那么尝试在编辑器中打开post-commit钩子,该编辑器允许您像Emacs、TextMate或Vim那样更改行尾(在Windows上,我相信Notepad+会更改,但我不是Windows型的),并删除第一行末尾的额外字符(可能还有所有其他行)。
发布于 2010-02-03 23:19:42
下面是来自svn.apache.org的post-commit.tmpl .tmpl的前几行代码
#!/bin/sh
# POST-COMMIT HOOK
#
# The post-commit hook is invoked after a commit. Subversion runs
# this hook by invoking a program (script, executable, binary, etc.)
# named 'post-commit' (for which this file is a template) with the
# following ordered arguments
#
# [1] REPOS-PATH (the path to this repository)
# [2] REV (the number of the revision just committed)
#
# The default working directory for the invocation is undefined, so
# the program should set one explicitly if it cares第一行告诉shell这是一个shell脚本,并给出了/bin/sh作为该脚本的解释器的路径。您看到的错误消息表示shell找不到解释器。尝试运行
which sh检查sh在哪里。
我之所以让您使用unset PATH,是因为很多常见的钩子脚本错误都与路径问题有关。
发布于 2010-02-03 23:58:56
正如larrys所指出的,我的提交后脚本有windows行结尾(我在notepad++中编辑,并通过FTP上传)。我修复了这个问题,在VIM中打开文件并输入
:set fileformat=unixhttps://stackoverflow.com/questions/2190218
复制相似问题